?
Solved

Rename a long list of files

Posted on 2004-04-15
3
Medium Priority
?
417 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.
Suggested Courses

771 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