Solved

Rename a long list of files

Posted on 2004-04-15
3
412 Views
Last Modified: 2010-04-21
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.

0
Comment
Question by:bradjensen
  • 2
3 Comments
 
LVL 6

Expert Comment

by:bira
ID: 10835482
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'.
0
 
LVL 6

Accepted Solution

by:
bira earned 125 total points
ID: 10835524
ooopsss
little bug above.
use this

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
0
 

Author Comment

by:bradjensen
ID: 10835670
Perfect.  That works well.  Thanks bira!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now