OSX difference from Linux

If you want to rename a file from the command line you use the mv command. Escape special characters (like spaces, asterisks, quotes, etc.) with a backslash. The backslash character itself is escaped with a backslash. So for example, ‘girl w/ hoop’ would be ‘girl\ w\/\ hoop’

I tried running this command


mv GIRL\ W\/HOOP.jpg GIRL\ WITH\ HOOP.jpg

and got back this error message


usage: mv [-f | -i | -n] [-v] source target
       mv [-f | -i | -n] [-v] source ... directory

You can also put the file name in quotes like so


mv 'GIRL W/HOOP.jpg' 'GIRL WITH HOOP.jpg'

And you don’t need to worry about spaces and special characters.

Except that OSX doesn’t treat the / in a file name as a slash. It coverts it to a colon.

To see this, drag a file with a forward slash from the desktop to the terminal. Note what happens.


/Desktop/GIRL\ W:\ HOOP.jpg

Spaces are escaped, but the forward slash is converted to a colon.

So to get my move command to work I need to do this.


mv GIRL\ W:HOOP.jpg GIRL\ WITH\ HOOP.jpg

And it’s happy.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.