vendredi 14 février 2020

multiple IF else conditions issue

I have an issue where I want to segregate / split file based on search item into multiple files.
if I see add I want to put that line to addfile. similar to changeprop, insert and if I cannot find any match then to otherfile. I'm unable to process the if else conditions.

SETLOCAL enabledelayedexpansion
SET "File=%AllActionScriptsMergedNotOrderedFile%"

FOR /F "tokens=* delims=" %%a in ('TYPE "%File%"') DO (
 SET "eachline=%%a"
    IF /i "!eachline:~0,3!" == "ADD " (ECHO !eachline!>>"%ADDActionScriptsMergedFile%")
    ELSE(IF /i "!eachline:~0,9!" == "ADDINSERT" (ECHO !eachline!>>"%ADDINSERTActionScriptsMergedFile%")
        ELSE(IF /i "!eachline:~0,3!" == "MOV" (ECHO !eachline!>>"%MOVEActionScriptsMergedFile%")
            ELSE(IF /i "!eachline:~0,6!" == "INSERT" (ECHO !eachline!>>"%INSERTPROPActionScriptsMergedFile%")
                ELSE(IF /i "!eachline:~0,10!" == "CHANGEPROP" (ECHO !eachline!>>"%CHANGEPROPActionScriptsMergedFile%")
                            ELSE (ECHO !eachline!>>"%OTHERPROPActionScriptsMergedFile%")
                    )
                )
            )
        )
)

Aucun commentaire:

Enregistrer un commentaire