if %programName%=="CD41_2018" or IF %programName%=="CD41_2019"
(
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
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
You would like to look for all zip files in the "Datefile" Folder as well as any folders underneath the "Datefile" folder and copy all of them to your destination folder.
FOR /R "%ProgramPath%\%programName%\%dateFile%" %%A IN (*.zip) DO (
COPY "%%~A" "%BackupPath%\%programName%\"
)
setlocal enabledelayedexpansion
echo off
set "patternList="
if /i "%programName%"=="CD41_2018" set "patternList=*_CD391N.txt *_CD533.txt *_CD391C.txt *_CD391E.txt"
if /i "%programName%"=="CD41_2019" set "patternList=*_CD391N.txt *_CD533.txt *_CD391C.txt *_CD391E.txt"
if /i "%programName%"=="CD42" set "patternList=*_CD539C.txt *_CD539E_CD390.txt"
if /i "%programName%"=="C520MCA" set "patternList=*_C520CH_CCk.txt *_C520EU_CBS.txt *_C520NA.txt *_C520TW_CCZ.txt"
if not defined patternList goto :eof
:Loop
for %%a in ("%patternList%") do (
set "fileMask=%%a"
echo Processing '!fileMask!' ...
for /f "tokens=*" %%a in ('dir /b /s /a-d "%ProgramPath%\%programName%\%dateFile%\!fileMask!"') do (
echo Backing up '%%~nxa' ...
set "_CopyCMD=copy "%%~a" "%BackupPath%\PAT BTT Text Files\%programName%\New\""
ECHO !_CopyCMD!
CALL !_CopyCMD!
)
)
pause
GOTO :EOF
Expert Comment
by:Bill Prew
ID: 42523570
1d
I can't understand what you are asking based on:
zip file i need to move completely then only i need to copy some files and delete the old txt file and move the new txt file in no 2 code to the destination.
Please try added further explanation and break this down very clearly to what you need help with. As worded I doubt any experts will know what you want, and won't be able to help as a result.
If you need two possible options to do the same thing, make a block of code that gets called.
Also, your
IF %programName%=="CD42"
parts PROBABLY should be
IF "%programName%"=="CD42"
Unless %programName% includes the quotes.
I'd probably do something like:
Open in new window
This assumes only one possible %programName%.