call setfile.bat
echo Visiting the file: %file%
:: User specified visit code replace this line
find "%file%" /v
copy > nul
goto loop
:restore
if exist del
if exist del
if exist del
if exist setfile.bat del setfile.bat
:end
VisitI.bat - 对指定路径指定DIR信息的文件进行遍历操作的的程序
:: VisitI.bat - 对指定路径指定DIR信息的文件进行遍历操作的的程序
:: 第一参数为指定的DIR信息项,第二参数为要遍历的路径(缺省为当前路径)
:: 注意:DIR信息项可以是文件名,扩展名,日期,时间等DIR命令提供的目录信息项
:: 可以同时使用多项,但必须加一对引号,参数格式也须严格符合DIR的信息格式
@echo off
:main
if [%1]==[] goto end
:init
if exist if exist goto loop
set info=%1
set base=%2
if [%2]==[] set base=.
dir %base%. /s /a /b >
echo e 100 ''''set file='''' >
echo w >>
echo q >>
:loop
fc nul /n | find " 1:" > setfile.bat
if errorlevel 1 goto restore
debug setfile.bat nul
call setfile.bat
dir "%file%" | find %info% > nul
if not errorlevel 1 echo Visit file: "%file%"
:: if not errorlevel 1
find "%file%" /v
:: "%file%" 参数决定了所匹配的子目录下的所有文件和目录均不会再次匹配
copy > nul
goto loop
:restore
if exist del
if exist del
if exist del
if exist setfile.bat del setfile.bat
set info=
set file=
set base=
:end
Visit.bat - 文件遍历批处理程序
:: Visit.bat - 文件遍历批处理程序
:: Will Sort - 10/17/2004 - V2
::
:: 程序用途:
:: 对指定文件集/目录集/文件列表执行指定操作
::
:: 命令行说明:
:: 1. VISIT 文件集/目录集 [参数]
:: 对文件集/目录集执行指定操作
:: 2. VISIT @ 文件列表
:: 对指定文件列表中的文件执行指定操作
::
:: 注意事项:
:: - 文件集/目录集 中可包含有效路径和通配符
:: - 路径缺省为当前路径,文件集缺省为 *.* (并非所有文件)
:: - 文件集/目录集 含空格时需用双引号引起
:: - [参数] 支持的DIR开关: /S /A /O /L等不与 /B 冲突者
:: - [参数] 不支持的DIR开关: /W /P /V 等与 /B 冲突者
:: - [操作] 由调用者预先写入 visitcmd.bat 中
:: - [操作] 中使用 %VisitFile% 引用遍历文件
:: - 程序检查检查 [文件列表] 是否存在,但不检查它是否有效
:: - 不遍历隐藏/系统目录下的目录和文件(在命令行中指定时例外)
::
:: 用法示例:
:: visit c: /ad /s 遍历C盘所有目录,包含子目录
:: visit "C:My document" /a-d 遍历"C:My document"下所有文件
:: visit C:*.zip /a /s 遍历C盘所有.zip压缩包,包含子目录
:: 如想遍历多个文件/目录集,可多次使用"DIR 文件集 /a /s>>文件列表"









