Getting "The syntax of the command is incorrect." error

Updated: 12/29/2017 by Computer Hope

Computer errorIn 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 below commands.

Copying a file with a space

In this first example, we're copying the file "computer hope.txt" into the hope directory. Without the quotes around the file, you will 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

Next, the below command would move the file "computer hope.txt" into the hope directory. Again, without quotes you will get the error message.

move "computer hope.txt" hope

Renaming a file with a space in the file name

Finally, the below command would rename the same file to "example file.txt", which also has a space in the file name.

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

Additional information