的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
为什么不进入下一个目录? Echo only test 2
答案 0 :(得分:1)
现在使用您的新代码完全重写。这可以让你更接近你想做的事情。希望我修复了你的程序中的所有其他错误。我故意缩进我的代码,以便我可以看到代码块的开始和结束位置。更容易看到和理解代码是如何工作的。
的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