The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Rename a file name Aswarth Shell Programming and Scripting 0 06-04-2008 03:18 PM
Not able to rename file MANISH KU Shell Programming and Scripting 2 06-27-2007 05:07 AM
File rename redlotus72 UNIX for Dummies Questions & Answers 1 03-09-2006 11:52 AM
how to rename a file before and after a ftp? forevercalz Shell Programming and Scripting 2 10-28-2005 10:19 AM
Help with multiple file rename - change case of part of file name steve7 UNIX for Dummies Questions & Answers 7 06-30-2005 02:41 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 08-01-2008
sea krait sea krait is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 2
Advanced File Rename help

So, I am so new that I can't even call myself a unix user. I have an aptitude for programing, but I don't know the language. Anyway, here is my problem:

I have to rename a batch of files that look like:
2001_0001.asc
2001_0002.asc
.
.
.
2006_0548.asc

The names are a date code, but they need to be altered such that 2001_0001.asc becomes 2000_183.asc, 2001_0184 becomes 2001_001, and 2006_0548.asc becomes 2006_365.asc.

so, I think it should start like:

for i in `ls*`
do

then things get a bit hazy
I will now convert to semi-programing speak

split aaaa_bbbb.asc into aaaa and bbbb
interpret strings aaaa and bbbb as numbers x and y respectively
if y - 183 < 1,
then x' = x - 1 and y' = y - 183 + 365,
else x' = x and y' = y - 183.
convert numbers x and y to strings aaaa' and bbb' (note the three digits
in bbb such that y' = 1 will convert to bbb' = 001)
rename file i to aaaa'_bbb'.asc

any help would be appreciated
thanks,
-TT
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0