Home  >  Article  >  How to rename and move files with spaces in their names from the command line

How to rename and move files with spaces in their names from the command line

王林
王林forward
2023-04-17 10:55:022324browse

Interacting with files with spaces in their names from the quoted command line

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"

Modify files with spaces in their names from the terminal by escaping

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!

Statement:
This article is reproduced at:yundongfang.com. If there is any infringement, please contact admin@php.cn delete