Home » Infrastructure » Unix » Renaming Files
Renaming Files [message #244133] Mon, 11 June 2007 12:36 Go to next message
Krishna_dev
Messages: 32
Registered: May 2007
Member
Hello, I have several files with the following naming convention sitting in the same directory.
MyFile.0001.dat
MyFile.0002.dat
MyFile.0003.dat
MyFile.0004.dat
MyFile.0004.dat

I would now like to rename each file and append it with a prefix of Processed so they will now read like:
ProcessedMyFile.0001.dat
ProcessedMyFile.0002.dat
ProcessedMyFile.0003.dat
ProcessedMyFile.0004.dat
ProcessedMyFile.0004.dat

Could someone please tell me how to do this using Korn shell. An in depth example would be much appreciated.
Re: Renaming Files [message #244146 is a reply to message #244133] Mon, 11 June 2007 13:36 Go to previous message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
ls -1 Myfile* | awk '{print "mv "$1" Processed"$1}' > temp.sh ; sh ./temp.sh

above is UNTESTED
You should make copies for backups before starting

[Updated on: Mon, 11 June 2007 13:36] by Moderator

Report message to a moderator

Previous Topic: cut a variable
Next Topic: Unix ( PL-SQL )
Goto Forum:
  


Current Time: Fri Mar 29 01:06:28 CDT 2024