Getting "The syntax of the command is incorrect." 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 first 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
Next, the following command would move the file "computer hope.txt" into 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
Finally, the following 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"