如何在多个目录中搜索(How search in multiple directories)

编程入门 行业动态 更新时间:2024-10-26 02:33:56
如何在多个目录中搜索(How search in multiple directories)

的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

为什么不去下一个目录? 回声只测试2

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

最满意答案

现在使用您的新代码完全重写。 这可以让你更接近你想做的事情。 希望我修复了你的程序中的所有其他错误。 我故意缩进我的代码,以便我可以看到代码块开始和结束的位置。 更容易看到和理解代码是如何工作的。

的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

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

更多推荐

本文发布于:2023-07-15 15:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1115307.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   如何在   目录中   directories   multiple

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!