Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to modify file name 2

Status
Not open for further replies.

bluedragon2

IS-IT--Management
Jan 24, 2003
2,642
US
Is it possible to run a scrpit to modify the file names in a directory? I have a name like:

spx@xxx.xxx.xx.xx@09.25.03-05:06:23

I need to change the : to .

Thanks


Blue [dragon]

If I wasn't Blue, I would just be a Dragon...
 
Try:

ls -1 /mydir|while read f
do
nf=$(echo $f|tr ':' '.')
mv $f $nf
done

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
I had an error occur with this script but once the "nf=$" was replaced with a "nf=`" and then a "`" was added to the end of the line "nf=`(echo $f|....)` it worked.

ls -1 /mydir|while read f
do
nf=$(echo $f|tr ':' '.')
NOTE: The above line errored out so I changed it to

nf=`(echo $f|tr ':' '.')`
mv $f $nf
done
 
Works great, thanks



Blue [dragon]

If I wasn't Blue, I would just be a Dragon...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top