elwaysgod
November 7th, 2007, 11:04 AM
Hi,
Hopefully someone can look at this batch and help me figure out why it's not giving me desired output. I'm not understaning the 'for f tokens lines' and what they are saying :(
*************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 a sub 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
Hopefully someone can look at this batch and help me figure out why it's not giving me desired output. I'm not understaning the 'for f tokens lines' and what they are saying :(
*************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 a sub 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