Hi,
I have a script that reads a directory structure then dynamically builds me a .bat file with 'xcopy' commands. However it's only giving me results if the directories go down to atleast 2 levels from starting point. I need it go give me the directories that only go 1 level past starting point too. As long as they are not in the 'excluded' list.
Starting Point is D:\Hyperion\essbase\app\
******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. And 'testplan' is not on the excluded list. If I put a dummy dir under testplan, it works correctly. However I can't do that as the software uses these dirs.
**** Current Batch that 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 ROCDIR "%%a"
popd
if not exist "%outFile_CopyAppDir%" echo Could not find anything to process&goto :EOF
echo Processing writing to %outFile_CopyAppDir%
goto :EOF
ROCDIR
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 ROCESS "%%a" "%~1"
popd
goto :EOF
ROCESS
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
Thanks for all help this may generate...
Sam
I have a script that reads a directory structure then dynamically builds me a .bat file with 'xcopy' commands. However it's only giving me results if the directories go down to atleast 2 levels from starting point. I need it go give me the directories that only go 1 level past starting point too. As long as they are not in the 'excluded' list.
Starting Point is D:\Hyperion\essbase\app\
******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. And 'testplan' is not on the excluded list. If I put a dummy dir under testplan, it works correctly. However I can't do that as the software uses these dirs.
**** Current Batch that 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 ROCDIR "%%a"
popd
if not exist "%outFile_CopyAppDir%" echo Could not find anything to process&goto :EOF
echo Processing writing to %outFile_CopyAppDir%
goto :EOF
ROCDIR
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 ROCESS "%%a" "%~1"
popd
goto :EOF
ROCESS
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
Thanks for all help this may generate...
Sam