I'm trying to rename a file with a hyphen at the beginning of its name and both this:
mv -example-file-name example-file-name
mv '-example-file-name' example-file-name
mv: invalid option -- 'e'
Most GNU/Linux commands allow a
A small test
RedGrittyBrick's answer is very good. Another option is:
A small test:
You can use this:
that it can rename all file :) if your file name :
after run code, your file name become:
This trick works for me in times of desperation. YMMV
You have to escape the hyphen for rename to recognize it. Why rename doesn't respect single quotes or offer an override of some kind is beyond me.
This is the only method I've seen that reliably handles a leading hyphen using rename. I agree with the other posts on using mv, but if you can't use mv for any reason, this works.