You are not logged in.
Pages: 1
I'm trying to rename some mp3 files but I've run into a problem. The filenames begin with a hyphen (something like this, for example: "- 1. song name.mp3") which seems to affect how the mv command behaves... Anyways, here is the command I used:
for i in *.mp3; do j=`echo $i | sed 's/-\ /0/g'`; mv "$i" "$j"; done
and here is the output I get:
mv: invalid option --
Try `mv --help' for more information.
mv: invalid option --
Try `mv --help' for more information.
(...)
I guess the hyphen from the filename gets interpreted by the mv command as an unrecognized option. Is there any way to escape this hyphen somehow? I can rename these files using thunar batch rename without problems but I'd love to learn how to deal with cases like this in the future. Thanks for any help with this.
Last edited by fwojciec (2008-02-02 21:45:47)
Offline
Use "mv --"
You may also like mmv in AUR.
Offline
Thanks, "mv --" works great. I'll have a look at mmv as well.
Offline
Pages: 1