jeudi 3 juin 2021

IF ELSE Statements in Batch files

So I've come from much newer languages and really struggling to create an IF-ELSE structure I've tried the following and nothing seems to be working. What am I doing wrong? What is the correct way of doing this?

IF "%MEETING_TYPE%" == "GM (
    ::copying the file c to d
    (echo '2 && echo [enter]) >> macro.mac
    )

IF "%MEETING_TYPE%" == "AGM"( 
    ::moving the file c to d
    (echo [tab] && echo '2 && echo [enter]) >> macro.mac
    )

IF if "%MEETING_TYPE%" == "EGM" (
    ::copying a directory c from d, /s:  boş olanlar hariç, /e:boş olanlar dahil
    (echo [tab] && echo [tab] && echo '2 && echo [enter]) >> macro.mac
    )

IF "%MEETING_TYPE%" == "CM" (
    ::moving a directory
    (echo [tab] && echo [tab] && echo [tab] && echo [tab] && echo '2 && echo [enter]) >> macro.mac
    )

And also tried

IF "%MEETING_TYPE%" == "GM"(
    (echo '2 && echo [enter]) >> macro.mac
    ) ELSE (
        IF "%MEETING_TYPE%" == "AGM"(
        (echo [tab] && echo '2 && echo [enter]) >> macro.mac
        ) ELSE (
            if "%MEETING_TYPE%" == "EGM"(
            (echo [tab] && echo [tab] && echo '2 && echo [enter]) >> macro.mac
            ) ELSE (
                "%MEETING_TYPE%" == "CM"(
                (echo [tab] && echo [tab] && echo [tab] && echo [tab] && echo '2 && echo [enter]) >> macro.mac
                
                )
            )
        )
    )

Aucun commentaire:

Enregistrer un commentaire