Link to home
Start Free TrialLog in
Avatar of bradjensen
bradjensen

asked on

Rename a long list of files

I need to rename a long list of files (approximately 2500 files).  These files are in a directory with thousands of other important files.  The filenames are formatted in this manner:

ABCD.EFGHIJ.YYYYMMDD.HHMMSS.checked

Where 'ABCD.EFGHIJ' are varialble alpha characters.  YYYYMMDD.HHMMSS is the time/date stamp.  The time/date stamp represents when the file was created.  I need all files which were created on April 1, 2004 between the hours of 1300 and 1800 (not beyond 1800).  Also, I need to remove the .checked extension from each file.

Avatar of bira
bira

for i in `ls ABCD.*|grep 20040401|grep -E "13|14|15|16|17"`
do
x=`echo $i|cut -c1-27`
mv $i $x
done

 Note that 'ABCD.' must be a stardard.
 I would advice you to test it by replacing the 'mv $i $x'  for
 'ls $x'.  
 Once you find out the files are those you really want, then
 run with 'mv $i $x'.
ASKER CERTIFIED SOLUTION
Avatar of bira
bira

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bradjensen

ASKER

Perfect.  That works well.  Thanks bira!