标题: [文本处理] [已解决]批处理搜索当前目录及子目录中包含指定字符的文件名并写入另一文件中 [打印本页]
作者: temp 时间: 2011-5-16 23:06 标题: [已解决]批处理搜索当前目录及子目录中包含指定字符的文件名并写入另一文件中
本帖最后由 temp 于 2011-5-19 12:32 编辑
搜索命令:- @echo off&setlocal enabledelayedexpansion
- title= 查找包含.dll .ax字符行
- for /f "delims=" %%i in ('dir/b/s/a-d "%~dp0Bin\*.dll"') do echo %%i>>a.txt
- for /f "delims=" %%i in ('type "a.txt"') do (if not defined %%i set %%i=A & echo Regsvr32/s "%%i">>"1.cmd")
复制代码
结果:- Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AddrSearch.dll"
- Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AFCtrl.dll"
- Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AFUtil.dll"
- Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AppCom.dll"
- Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AppFramework.dll"
- Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AppMisc.dll"
- Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AppUtil.dll"
- Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AuCommon.dll"
- Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\audioengine.dll"
- ... ...
复制代码
我希望得到的结果:- Regsvr32/s "Bin\XVEngine.dll"
- Regsvr32/s "Bin\AddrSearch.dll"
- Regsvr32/s "Bin\AFCtrl.dll"
- Regsvr32/s "Bin\AFUtil.dll"
- Regsvr32/s "Bin\AppCom.dll"
- Regsvr32/s "Bin\AppFramework.dll"
- Regsvr32/s "Bin\AppMisc.dll"
- Regsvr32/s "Bin\AppUtil.dll"
- ... ...
复制代码
谢谢!
作者: CrLf 时间: 2011-5-16 23:14
用%%~nxi代替%%i
作者: temp 时间: 2011-5-18 21:48
用%%~nxi代替%%i
zm900612 发表于 2011-5-16 23:14
谢谢!
我试了,没成功,请帮忙贴上完整的代码
作者: CrLf 时间: 2011-5-18 22:50
- @echo off&setlocal enabledelayedexpansion
- title= 查找包含.dll .ax字符行
- for /f "delims=" %%i in ('dir/b/s/a-d "%~dp0Bin\*.dll"') do echo %%i>>a.txt
- for /f "delims=" %%i in ('type "a.txt"') do (
- if not defined %%i set %%i=A & echo Regsvr32/s "Bin\%%~nxi">>"1.cmd"
- )
复制代码
作者: temp 时间: 2011-5-18 23:50
本帖最后由 temp 于 2011-5-19 12:31 编辑
@echo off&setlocal enabledelayedexpansion
title= 查找包含.dll .ax字符行
for /f "delims=" %%i in ('dir/b/s/a-d "%~dp0Bin\*.dll"') do echo %%i>>a.txt
for /f "delims=" %%i in ('type "a.txt"') do (
...
zm900612 发表于 2011-5-18 22:50
谢谢!
已达到预期效果(问题出在重复执行了一遍一楼的代码)
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |