本帖最后由 jwwlchen 于 2012-10-27 15:04 编辑
回复 6# forfiles
我的批处理出问题了 ,能帮我看下问题出在哪里了吗? 谢谢,在最后删除重复文件时会把所有文件删掉?- set searchfile=f:\temp
- set tempfile=c:\templog
- set logfile=c:\output
- set errcode=1111
-
- :start
- if not exist %logfile%\nul mkdir %logfile%
- if not exist %tempfile%\nul mkdir %tempfile%
- del %tempfile%\. /q
- del %logfile%\. /q
-
- :search logs by sn
- for /f "delims=" %%a in ('type sn.txt') do (
- copy %searchfile%\%%a*.txt %tempfile%\ /y
- )
-
- :search logs by errcode
- for /f "tokens=2 delims=:" %%a in ('findstr /c:"%errcode%" %tempfile%\*.txt') do copy c:%%a %logfile%\. /y
-
- :del repeat logs
- cd /d %logfile%
- for /f "tokens=1* delims=_" %%a in ('dir /b *.txt') do (
- if defined #%%a (
- del /f /q %%a_%%b
- ) else (
- set #%%a=1
- )
- )
复制代码
|