Getting 'The syntax of the command is incorrect' error

Updated: 12/29/2017 by Computer Hope
Computer error

In the Windows command line, when trying to copy, move, or rename a file or directory with a space, you may get the "The syntax of the command is incorrect" error message. This error message is generated when the Windows command line does not understand the syntax of the command because it is not formatted properly. To resolve this issue, surround any file name or directory name with spaces in it with quotes.

For example, if we had a directory or file name called "computer hope," you would enter the following commands.

Copying a file with a space

In this example, we're copying the file "computer hope.txt" into the hope directory. Without the quotes around the file, you get "The syntax of the command is incorrect" error message.

copy "computer hope.txt" hope

Moving a file with a space in the file name

The following command moves the file "computer hope.txt" to the hope directory. Again, without quotes, you get the error message.

move "computer hope.txt" hope

Renaming a file with a space in the file name

The following command renames the same file to example file.txt, also having a space in the file name.

rename "computer hope.txt" "example file.txt"