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.
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
Then run below commands:
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.