≡ Menu

The syntax of the command is incorrect

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 in dir1/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.

{ 6 comments… add one }
  • KM

    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…

    forfiles /M *.pdf /C "cmd /c rename @file \"@fname - post.pdf\""

    Can you help to advise? Thanks in advance.

    Regards
    KM

  • admin

    Looks like it works if you move @fname out of the quotes.

    forfiles /M *.pdf /C "cmd /c rename @file @fname\" - post.pdf\""
  • Ray

    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

  • Bo

    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

  • Bo

    Then choose your folder CD is missing in the text above.

  • Bo

    Still missing …..CD

Leave a Comment