how to use multiple if statement without else

HI EXPERTS,

i am trying to move a some text files from sub folder to destination. i have a many programs so i am using If statements to do that copy.

if statement working only in first condition its not moving to another if condition. showing like syntax error. kindly help me.

code is:
SET ProgramPath=%CD%

SET BackupPath=\\ecc9000203\proj\DI_PMTI_SE\PAT\PAT\PATFiles

echo off

TITLE=%programName% BPNO Data serie

IF "%programName%"=="CD41_2018" goto SPLITTER

:SPLITTER
call :DeleteFolder

call :DeleteFolder "BackupPath"
:DeleteFolder [folder-path]

if %programName%=="CD41_2018"  OR IF %programName%=="CD41_20199"
(
for /f "tokens=*" %%A in ('dir /b /s /a-d "%ProgramPath%\%programName%\%dateFile%\*_CD391N.txt" "%ProgramPath%\%programName%\%dateFile%\*_CD533.txt"
      "%ProgramPath%\%programName%\%dateFile%\*_CD391C.txt" "%ProgramPath%\%programName%\%dateFile%\*_CD391E.txt"') do (
    copy "%%~A" "%BackupPath%\PAT BTT Text Files\%programName%\New\"
      ))
      pause
      TIME /T
IF %programName%=="CD42"
(
for /f "tokens=*" %%A in ('dir /b /s /a-d  "%ProgramPath%\%programName%\%dateFile%\*_CD539C.txt" "%ProgramPath%\%programName%\%dateFile%\*_CD539E_CD390.txt"') do (
    copy "%%~A" "%BackupPath%\PAT BTT Text Files\%programName%\New\"
      )))
pause
if %programName%=="C520MCA"
(
for /f "tokens=*" %%A in ('dir /b /s /a-d "%ProgramPath%\%programName%\%dateFile%\*_C520CH_CCk.txt" "%ProgramPath%\%programName%\%dateFile%\*_C520EU_CBS.txt"
      "%ProgramPath%\%programName%\%dateFile%\*_C520NA.txt" "%ProgramPath%\%programName%\%dateFile%\*_C520TW_CCZ.txt"') do (
    copy "%%~A" "%BackupPath%\PAT BTT Text Files\%programName%\New\"
      ))      
      pause

help me.. thank youuu
bhavani vAsked:
Who is Participating?
 
Bill PrewConnect With a Mentor Commented:
Here you go, please study this code until you understand all changes.

@echo off
setlocal

REM WHERE DOES ProgramName GET SET, I DON'T SEE IT???

SET ProgramPath=%CD%

SET BackupPath=\\ecc9000203\proj\DI_PMTI_SE\PAT\PAT\PATFiles

TITLE=%programName% BPNO Data serie 

IF "%programName%"=="CD41_2018" (

    set DoCopy=N
    if "%programname%" == "CD41_2018" set DoCopy=Y
    if "%programname%" == "CD41_20199" set DoCopy=Y
    if "%DoCopy%" == "Y" (
        for /f "tokens=*" %%A in ('dir /b /s /a-d "%ProgramPath%\%programName%\%dateFile%\*_CD391N.txt" "%ProgramPath%\%programName%\%dateFile%\*_CD533.txt" "%ProgramPath%\%programName%\%dateFile%\*_CD391C.txt" "%ProgramPath%\%programName%\%dateFile%\*_CD391E.txt"') do (
            copy "%%~A" "%BackupPath%\PAT BTT Text Files\%programName%\New\"
        )
    )

    if "%programname%" == "CD42" (
        for /f "tokens=*" %%A in ('dir /b /s /a-d  "%ProgramPath%\%programName%\%dateFile%\*_CD539C.txt" "%ProgramPath%\%programName%\%dateFile%\*_CD539E_CD390.txt"') do (
            copy "%%~A" "%BackupPath%\PAT BTT Text Files\%programName%\New\"
        )
    )

    if "%programname%" == "C520MCA" (
        for /f "tokens=*" %%A in ('dir /b /s /a-d "%ProgramPath%\%programName%\%dateFile%\*_C520CH_CCk.txt" "%ProgramPath%\%programName%\%dateFile%\*_C520EU_CBS.txt" "%ProgramPath%\%programName%\%dateFile%\*_C520NA.txt" "%ProgramPath%\%programName%\%dateFile%\*_C520TW_CCZ.txt"') do (
            copy "%%~A" "%BackupPath%\PAT BTT Text Files\%programName%\New\"
        )
    )

    pause

)

Open in new window


»bp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.