none
Cmd.exe script error... was unexpected at this time. RRS feed

  • Question

  • Hi there,

    I have the following ms-dos batch script to unzip all Esp*.zip files in the parent directory:

    if not exists ..\Esp*.zip EXIT 2
    "C:\Program Files\7-Zip\"7z e ..\Esp*.zip -o..\ -y

    As you can see in the first line, I am trying to exit the script if there are no Esp*.zip files in the parent directory. However, when I run the script I get the following error:

    ..\Esp*.zip was unexpected at this time.

    I appreciate any help, I apologize if this is not the right forum to ask this question, if so, please point me in the right direction.

    Thanks for all the help,

    -Eduardo





    Wednesday, June 14, 2017 6:14 PM

Answers

  • 1. There is no "if exists" command (run the command if /? for information). You would need to write "if exist" (no "s" on the end).

    2. This is not MS-DOS. Cmd.exe, despite appearances, has absolutely nothing whatsoever to do with MS-DOS. I edited your question title to reflect this.


    -- Bill Stewart [Bill_Stewart]



    Wednesday, June 14, 2017 6:21 PM
    Moderator

All replies

  • 1. There is no "if exists" command (run the command if /? for information). You would need to write "if exist" (no "s" on the end).

    2. This is not MS-DOS. Cmd.exe, despite appearances, has absolutely nothing whatsoever to do with MS-DOS. I edited your question title to reflect this.


    -- Bill Stewart [Bill_Stewart]



    Wednesday, June 14, 2017 6:21 PM
    Moderator
  • Thanks, Bill. It worked perfectly. Also, thanks for the heads-up on cmd.exe

    Best regards,

    -Eduardo

    Monday, June 19, 2017 2:32 PM