Trying to command

mv foo&foo.jpg images/

but get command not found, then if try and rename the file it won't let me.


Use single quotes. For example:

mv 'foo&foo.jpg' images/

Unless you quote or escape the & symbol, it's interpreted as a special token by the shell.


One more way , use escape character

mv file\&filename any

That will rename file&filename named file into any name.


This requires many steps but I would try this when every other option fails.

Lets say foo&foo.jpg is in /a/b along with other files, I would create /a/b_new and move all files there probably with multiple moves to match all the files but foo&foo.jpg.

Then run below commands: cd /a; cp /a/b/* /a/b_new/foo.jpg; rm -r /a/b; mv /a/b_new /a/b;

Note: Some flavors might require mv -i or mv -R to rename directory.

  • How does this answer the question? – Will Vousden Mar 4 '16 at 9:51
  • Hmm, Read it one more time. – ObiWanKenobi Mar 4 '16 at 14:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.