The easiest way to interact with files with spaces in their names is to use quotes.
For example, if we try to move a file named "Sample File.pdf", the command used is as follows:
mv "Sample File.pdf" ~/ Path/To/Destination/
Or rename "Sample File.pdf" will look like this:
mv "Sample File.pdf" "Sample File 2. pdf"
You can also use backslashes to escape the spaces, but for most users this will It's not as simple as using quotes. This will look like this:
mv Sample\ File.pdf ~/Path/To/Destination/
Note how the \ precedes the space in the file name.
Again, using quotes is the easiest and most straightforward method for most users, but you are free to use the escaped slash method as well.
The above is the detailed content of How to rename and move files with spaces in their names from the command line. For more information, please follow other related articles on the PHP Chinese website!