Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window Batch - Modification Needed

Status
Not open for further replies.

elwaysgod

Technical User
Nov 6, 2007
4
US
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 :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


Thanks for all help this may generate...

Sam
 
Also I could not find a 'Windows Batch' forum, thus I thought this was closest area. I don't want to make anyone mad for posting 'Windows Batch' question in VB area.

Sam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top