Solved

Rename a long list of files

Posted on 2004-04-15
3
411 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
Comment Utility
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
Comment Utility
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
Comment Utility
Perfect.  That works well.  Thanks bira!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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 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…

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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now