How to copy, move, or rename files with a space in the name

Updated: 01/05/2018 by Computer Hope
file with space in name

In the Windows command line, any file or directory containing a space must be surrounded with quotation marks for it to be recognized. For example, if you wanted to rename the file "stats baseball.doc" to "stats_baseball.doc," you could type the command below and press Enter.

move "stats baseball.doc" stats_baseball.doc

The reason quotation marks are needed on files with spaces is the command line doesn't know where the file name begins or ends without them, due to the spaces. The command line uses the space character to separate the name of the file being renamed from the new name of the file. When a file contains spaces, it must be surrounded in quotation marks to ensure the proper file is renamed. Otherwise, the command line interprets the words following each space as new file names.

If you want to rename a file name containing spaces to a new file name with spaces, place quotation marks around both file names, as in the following example.

move "stats baseball.doc" "stats baseball pitching.doc"

The same examples above can be applied to the copy, rename, delete, or other commands in the Windows command line that involve a file name with a space.