FreeDoughnut |
07-19-2006 03:56 PM |
Bash Renaming (removing a string from filenames)
I switched CD ripping programs recently, and the first one didn't organize my music in folders. The new one does, so I did it manually. What I have now is:
Quote:
/mnt/music/music/Pink Floyd/Dark Side Of The Moon/Pink Floyd - Eclipse.ogg #OLD
/mnt/music/music/Rush/Moving Pictures/Tom Sawyer.ogg #NEW
|
So I'm working on a bash command to change the old ones to be like the new ones. What I have so far from my Googling is:
Quote:
for i in `ls`; do mv $i `echo $i | sed ' s/Pink\ Floyd\ -\ /\ /' `; done
|
But due to some discrepency between sed and mv and the for loop, mv processes each space seperated part as a seperate file, so I get errors like:
Quote:
mv: invalid option -- \
Try `mv -help' for more information.
mv: cannot stat `Us\\': No such file or directory
mv: cannot stat `And\\': No such file or directory
mv: cannot stat `Them.ogg': No such file or directory
|
However,
Quote:
mv "Pink Floyd - Money.ogg" `echo "Pink Floyd - Money.ogg" | sed ' s/Pink\ Floyd\ -\ //' `
|
gives me "Money.ogg". How do I coordinate every program's way of processing "\ "s and " "s so that I can make my music collection consistent?
Thanks for any help, and I'm a newbie to bash scripting, so please explain any changes to my original command.
|