Getting 'The syntax of the command is incorrect' error
While using the Command Prompt in Windows, you may have come across the error message "The syntax of the command is incorrect." Whether you're trying to copy, move, or rename a file or directory, this message is generated when you try to pass an incorrect argument through the Windows command line. Essentially, Windows does not understand the syntax of the command because it is not formatted properly.
The following section contains examples of how this error may be generated as well as possible solutions.
Syntax
While there are many ways to generate this error message, it always comes down to one thing: syntax. It may seem obvious, but double-check to ensure what you're entering into the command line has the proper characters and only one destination/desired change.
For example, if you were to try to copy a file, but had two destinations (like the example below), you would see the aforementioned error message.
Two destinations
copy "computer hope.txt" hope hope2
Spacing
"The syntax of the command is incorrect" error message is also generated when dealing with file names containing spaces. Any file name with spaces needs to be surrounded by double quotes. In the following examples, we're entering commands using computer hope.txt, which is a text file.
Copy command
This example copies the comptuerhope.txt file into the hope directory.
copy "computer hope.txt" hope
Move command
This example moves the original comptuerhope.txt file into the hope directory.
move "computer hope.txt" hope
Rename command
The example renames the comptuerhope.txt file to different file.txt, which also has a space in the file name.
rename "computer hope.txt" "different file.txt"