Rename a file with mv

2 respostas [Última entrada]
Joined: 01/04/2015

This ought to be a trivial task ...
But I'm faced with a directory of 75 files with similar names, which mv ought to handle with ease:
mv oldfilename newfilename
except that my old file name has spaces:
mv old file name newfilename
which elicited the response:
"newfilename" is not a directory

I've always resisted leaving spaces in filenames, but this time I was in a hurry.
Is there a geek way that's quicker than renaming them one-at-a-time with the
file manager ?

George Langford

Joined: 03/28/2021

When a file or directory name contains spaces you have to put its name between apostrophes, so the command would be:

mv 'old file name' newfilename

Greetings, JLB.

Joined: 01/04/2015

Thank You JLB !

The geek way is indeed quicker. Took me 32 minutes the hard way; and I made a couple of errors.

In all the Google pages that I consulted before asking my question, none brought up your most elegant method.

I shoulda known ... in the paste command, I routinely type paste -d '[space]' to signify separating the
files with spaces. Same idea.