In Unix, almost everything is a file. A directory is a special type of file that from the user's perspective can "contain" other files.
The error Not a directory
occurs because your existing file is not a directory, and since a directory is a type of file, and there cannot be two identically named files in one directory, the operation cannot be performed.
Bash tab completion should be able to do the right thing here if you just type mv 90843_O
and press tab. Otherwise, one way to properly escape the name is:
mv "90843_O\\\\'ConnorPaul_GeneralManager.jpg" dest.jpg
The double quotes remove the need to escape the '
, but the two backslash characters still need to be escaped (one extra backslash for each makes four backslashes). Another option is:
mv '90843_O\\'\'ConnorPaul_GeneralManager.jpg dest.jpg
Here putting the backslashes in single quotes removes the need to escape them, but you need to end the single quotes to add a literal '
. This is escaped after the quotes end.
Note the issue here is as much to do with having backslashes in the name as the single quote. To replace the \\'
sequence (since there are two backslashes in the filename in the question, both will cause problems) with an underscore for all files in a directory using a loop:
for file in *"\\\\'"*; do
mv -i "$file" "${file//"\\\\'"/_}"
done
The -i
will make mv
prompt if any files will be overwritten. Using prename
(rename
links to this on many systems):
prename -n 's:\\\\'\'':_:g' *"\\\\'"*
Remove the -n
when you are happy it is doing what you want. Note that the backslash characters should be escaped inside the perl expression here, even though there are single quotes around them (without the single quotes you would need eight backslashes since four would be removed by the shell and not be part of the perl expression).
Best Answer
mv "{{ THEME SANITIZED }}.hacks.css" myomega.hacks.css
will work.