This is a common error we would encounter while working with windows command prompt. It means that there’s something wrong in the arguments passed on to the command. Reasons could be any of the below.
- Not passing the right parameters to the command. For example,
Rmdir
command expects the directory name to be provided. Not adding this argument causes the error as below.c:\>rmdir The syntax of the command is incorrect.
- Passing more arguments than the command accepts
c:\>move file1 file2 file3 The syntax of the command is incorrect.
Move
command expects only two arguments, one for the actual file and the other for the destination file. Adding an extra argument causes the command to fail with the error. - This error can also occur even if we are passing the right number of arguments but the argument is not in the expected format. For example, ‘mkdir’ expects the directory path to be in the windows format like
dir1\dir2
. If you specify the path in Linux format as indir1/dir2
, it causes the error.c:\>mkdir dir1/dir2 The syntax of the command is incorrect.
How to resolve the error
If you encounter this error, the next thing to do is to check the usage of the command and identify what’s wrong in the command you ran. You can refer articles on this websiste for understanding syntax and example use cases. All the articles for windows commands are listed here. Windows commands reference.
Also, we can find the usage of a command by running the command with an argument /?
. For example to check the usage of shutdown
command, you can find it as below.
shutdown /?
Please add to the comments below if you are not able to fix the issue. I would do my best to reply back with a solution.
Hi,
I was trying to execute the following command but keep seeing “The syntax of the command is incorrect” message. I checked and reference to the example from rename files en masse” and cannot find what is wrong…
Can you help to advise? Thanks in advance.
Regards
KM
Looks like it works if you move @fname out of the quotes.
i need this to delete .zip files older than 7 days. im not sure what im doing wrong
forfiles /m *.zip /c “cmd /c Del *.zip ” /d -7
I have 5 folders with hundreds of photos, but all of them are converted to .chk.
I want convert them back to JPEG by using Command prompt. When I come to this point
“Then choose your folder CD ” I get a message “The syntax of the command is incorrect”.
The 5 folders are named FOUND.001 ……….005. The files start from FILE0000.chk
Please help me to solve this problem
Then choose your folder CD is missing in the text above.
Still missing …..CD
manage-bde -unlock c: -rp
I get told the syntax of the command is incorrect.
I’m putting my bitlocker password in for the recovery password with the _ inbetween each set of 6 numbers. I tried it without dashes too.
It’s sad that batch file don’t give a good answer, which would help to debug them. I encountered also the same message recently. My code was something like this:
> IF defined %TRUE% ( …
The problem here were the percent signs. So the correct way to write this was
> IF defined TRUE ( …
Hello everyone,
I am having a syntax error when executing my forfiles command.
My proposal is to develop a .bat script to everyday copy the last file backup from a folder to the one drive folder located in another drive “K”
This is the command I am using
My output result:
The syntax of the command is incorrect.
Thank you to all for your help!
Script:
CALL c:\work\flatfilechk.cmd “%x1%”,”%x2%”
The above line is working froml one cmd file, and the same I am trying from other cmd which is not working. I am getting the error like “the syntax of the command is incorrect?
Please give some resolution for this.