mv: invalid option -- '0'

Roger picture Roger · Jul 2, 2011 · Viewed 10.3k times · Source

How can I rename files with "-" in front of the filename, for example: "-0001.jpg"

Everyime I try to run:

for i in *; do mv "$i" "${i//-/}"; done

or:

for i in *; do mv "$i" "${i#*-}"; done

I got this error:

mv: invalid option -- '0'
Try `mv --help' for more information.

Thanks for any light!

Answer

jm666 picture jm666 · Jul 2, 2011
mv ./-00008.jpg to/some/where.jpg
   ^ - start with path...