Hi,
I have a script that dynamically creates another bat script that then performs some xcopy commands. However it does not include the directories in the xcopy bat script unless they have a sub dir. I need it to include them even if they dont have sub dir as long as they are not on the 'exclude' list.
Thanks for all help as I'm stumped as to why this is happening.
*************Current Directories that exist:**********************
D:\Hyperion\essbase\app\BU_CRTT\Crtt01\
D:\Hyperion\essbase\app\CapExp\Capital\
D:\Hyperion\essbase\app\CORPGA\Incstmt\
D:\Hyperion\essbase\app\testplan\
Note: In my current results it does not include a line for 'testplan' as it does not have another dir under it.
******** Current Batch athat creates Current Output********************
set ess_app_dir_source=D:\Hyperion\Essbase\App
set outFile_CopyAppDir=%~dp0CopyAppDir.bat
set excludeDirsAppCopy=$DM_APP$,migrationutils,ESSHFM,z_test
@echo off
setlocal
echo REM Begin to copy 'App' dir to backup location > %outFile_CopyAppDir%
pushd "%ess_app_dir_source%"
for /f "tokens=*" %%a in ('dir /b /ad 2^>NUL') do call :PROCDIR "%%a"
popd
if not exist "%outFile_CopyAppDir%" echo Could not find anything to process&goto :EOF
echo Processing writing to %outFile_CopyAppDir%
goto :EOF
:PROCDIR
for %%a in (%excludeDirsAppCopy%) do if /i "%%a"=="%~1" goto :EOF
pushd "%~1"
for /f "tokens=*" %%a in ('dir /b /ad 2^>NUL') do call :PROCESS "%%a" "%~1"
popd
goto :EOF
:PROCESS
for %%a in (%excludeDirsAppCopy%) do if /i "%%a"=="%~1" goto :EOF
echo xcopy "%ess_app_dir_source%\%~2" "%ess_app_dir_bkup%\%~2" /Y /S /E /i >> "%outFile_CopyAppDir%"
goto :EOF
**************Current Output*****************************:
REM Begin to copy 'App' dir to backup location
xcopy "D:\Hyperion\essbase\app\BU_CRTT" "E:\EssbaseBackup\Daily\App\BU_CRTT" /Y /S /E /i
xcopy "D:\Hyperion\essbase\app\CapExp" "E:\EssbaseBackup\Daily\App\CapExp" /Y /S /E /i
xcopy "D:\Hyperion\essbase\app\CORPGA" "E:\EssbaseBackup\Daily\App\CORPGA" /Y /S /E /i
***************Desired Output**************************
REM Begin to copy 'App' dir to backup location
xcopy "D:\Hyperion\essbase\app\BU_CRTT" "E:\EssbaseBackup\Daily\App\BU_CRTT" /Y /S /E /i
xcopy "D:\Hyperion\essbase\app\CapExp" "E:\EssbaseBackup\Daily\App\CapExp" /Y /S /E /i
xcopy "D:\Hyperion\essbase\app\CORPGA" "E:\EssbaseBackup\Daily\App\CORPGA" /Y /S /E /i
xcopy "D:\Hyperion\essbase\app\testplan" "E:\EssbaseBackup\Daily\App\testplan" /Y /S /E /i