Reputation: 29
start.bat
@echo off
CALL bat.bat "C:\Users\admin\Documents\test 2,C:\Users\admin\Documents\test 1" "*.xml *.txt *.html" "D:\Work\bat\batLog.txt"
bat.bat
for %%G in (%1) do (
echo %%~G
pushd "%%G"
If Exist "%%G" (
for /R %%H in ("%2") do (
if %%~zH LSS %3 (
>>"%4" (
echo %%~H
echo %%~tH
for /f "tokens=* delims=," %%i in ('type "%%~H"') do (
echo %%i
))) popd)))
pause
exit/b
why does not it go to the next directory? Echo only test 2
Upvotes: 0
Views: 52
Reputation: 14290
This is now a complete rewrite using your new code. This should get you closer to what you want to do. Hopefully I fixed all the other errors with your program. I purposely indent my code so that I can see where a code block begins and ends. Much easier to see and understand how the code is working.
start.bat
@echo off
call bat.bat "C:\Users\admin\Documents\test 2,C:\Users\admin\Documents\test 1" "*.xml *.txt *.html" "20000" "D:\Work\bat\batLog.txt"
bat.bat
@echo off
REM %1 = List of Folders
REM %2 = List of file masks
REM %3 = File Size for comparison
REM %4 = Log File
set "folders=%1"
set "folders=%folders:,=","%"
for %%G in (%folders%) do (
echo %%~G
If Exist "%%~G" (
pushd "%%~G"
for /R %%H in (%~2) do (
if %%~zH LSS %~3 (
>>"%~4" (
echo %%~H
echo %%~tH
for /f "tokens=* delims=," %%I in ('type "%%~H"') do (
echo %%~I
)
)
)
)
popd
)
)
pause
exit/b
Upvotes: 1