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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rename Multiple Files 1

Status
Not open for further replies.

hg4372

Technical User
Feb 9, 2009
43
US
I have hundreds of files that I need to rename or remove the : from. Any help would be appreciated.

Carsandtrucks.LOG_111709_14:41

Want all the files to look like this:

Carsandtrucks.LOG_111709_1441

Just need to remove the :
 
This perhaps?

[tt]for name in *:*
do
newname=$(echo $name|tr -d ':')
echo mv $name $newname
done[/tt]

if you're satisfied with the mv commands this displays, simply pipe this output to a shell

[tt]for name in *:*
do
newname=$(echo $name|tr -d ':')
echo mv $name $newname
done[red]|ksh[/red][/tt]


HTH,

p5wizard
 
Worked Perfect. Thank you very much.
 
Hi

Although it is not standard, many systems have some kind of [tt]rename[/tt]. Their syntax varies, but two are frequently used :
Code:
rename : '' *:*

[gray]# or[/gray]

rename 's/://' *:*
Check your system, maybe you have one of them.

Feherke.
 
Hi

Annihilannic said:
that one is gnu to me
Actually none of the [tt]rename[/tt] utilities I met was GNU. Those with the first syntax were part of the util-linux or util-linux-ng package. Those with the second syntax were mostly symlinks to a [tt]perl[/tt] script, [tt]prename[/tt], which was derived "from Larry Wall's original script eg/rename from the perl source", as a comment in the script says.

Feherke.
 
Sorry, I shouldn't tar all Linux-specific utilities with the same brush...

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top