Solved

Rename a long list of files

Posted on 2004-04-15
3
415 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Skill Development 15 195
NTP Server in VMware 5 395
MarkLogic 1 103
SCO 5.0.7 on HP Proliant DL380 G5 will not shutdown properly. 6 56
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

730 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