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

Updated: 01/05/2018 by Computer Hope

file with space in nameIn the Windows command line, any file or directory that contains 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 the quotation marks are needed on files with spaces is that the command line doesn't know where the file name begins or ends without them, due to the spaces. The space character is used on the command line 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 that the proper file is renamed. Otherwise, the command line will interpret the words following each space as new file names.

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

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

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

Additional information