ftp backup시 file수가 너무 많은 파일 transction으로 인한 문제점(??)해소를 위한 방법으로 현재 path 에서 subfolder N-depth 이상의 folder들은 모두 tar 로 묶어서 ftp backup을 하고자 한다. N-depth 이하도 물론 tar로 묶어야함.
- test.bat : test용 folder serch만 작성됨.
tar로 묵는부분은 작성되지 않음
@echo off
setlocal
::
:: init
::
set CUR_PATH=%~dp0
echo current path:%CUR_PATH%
set /a depth_cnt=0
set /a max_depth=3
set lastfolder=false
::
:: main
::
REM FOR /L %%G IN (1,1,3) DO (
call :dirlist
REM )
echo ######### goto end
goto :end
::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------
:dirlist
dir /a:d-s /b
for /f "delims=" %%f in ('dir /a:d-s /b') do (
set /a depth_cnt=0
call :DoInSub "%%f"
)
goto:eof
::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------
:DoInSub
if %depth_cnt% equ %max_depth% (
echo DO FINALJOB at %1
goto:eof
)
if not [%1]==[] (
set /a depth_cnt +=1
cd %1
echo. DO SOMETHING HERE :%~1 : %depth_cnt%
call:dirSublist %1
) else (
echo end of dirsub :%1:%depth_cnt%
)
goto:eof
::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------
:dirSublist
set /a listcnt=0
for /f "delims=" %%f in ('dir /a:d /b') do (
call :DoInSub "%%f"
set /a listcnt +=1
)
cd ..
set /a depth_cnt -=1
if %listcnt% equ 0 (
REM dir %1 /b
echo DO FINALJOB at %1
)
goto:eof
REM cd %~1
::--------------------------------------------------------
::-- Function section starts below here
::--------------------------------------------------------
:myGetFunc - passing a variable by reference
set "%~1=DosTips"
goto:eof
:end
endlocal