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

Shell Script Rename.....

Status
Not open for further replies.

kevmullet

Technical User
Feb 12, 2002
56
GB

OK so i have a bunch of files named like this:

"songname - artist.mp3"

and i would like them named like this:

"artist - songname.mp3"

Thanks for any help

-K
 
This should help. If you have more than one ' - ' then you'll have to figure where the substrings go.

for file in *.mp3
do
mv -- "$file" `echo $file |
sed 's/^\([^ ]*\) - \(.*\).mp3/\2 - \1.c/'`
done Cheers,
ND [smile]

bigoldbulldog@hotmail.com
 
That's

...
sed 's/^\([^ ]*\) - \(.*\).mp3/\2 - \1.mp3/'`
... Cheers,
ND [smile]

bigoldbulldog@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top