mercredi 24 juin 2015

batch else closing program

I have this code:

setlocal EnableDelayedExpansion

for /l %%s in ('0;1;47') do (
    set /a attempts=0
    set plugin_name_=!plugin_name[%%s]!.jar
    set plugin_URL_index_=!plugin_URL_index[%%s]!
    :dl
    :: Next line of code downloads file from URL argument 1 to file argument 2
    dl.vbs "https://foobar.com/" "Output\!plugin_name_!"
    if not exist "Output\!plugin_name_!" (
        :: If it did not download successfully...
        if not !attempts!==3 (
            echo Error downloading !plugin_name_!!
            echo Error downloading !plugin_name_!.>> Log.txt
            set /a attempts+=1
            goto dl
        ) else (
            echo Couldn't download !plugin_name_!.
            echo Couldn't download !plugin_name_!.>>Log.txt
        )
    ) else (
        echo Finished
    )
)

Since it's a little out of context, let me explain:

  • plugin_name[] is an array of names for the .jars I want to download.
  • plugin_URL_index[] is an array of download URLs for these files.
  • Keep in mind, plugin_nameplugin_name_ and plugin_URL_indexplugin_URL_index_

My issue is that upon reaching the second-nested-level else code, my file echos as normal, outputs to Log.txt as normal, but then exits.

I don't know why; I'm pretty confused.

Aucun commentaire:

Enregistrer un commentaire