[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] [已解决]批处理搜索当前目录及子目录中包含指定字符的文件名并写入另一文件中

本帖最后由 temp 于 2011-5-19 12:32 编辑

搜索命令:
  1. @echo off&setlocal enabledelayedexpansion
  2. title=  查找包含.dll .ax字符行
  3. for /f "delims=" %%i in ('dir/b/s/a-d "%~dp0Bin\*.dll"') do echo %%i>>a.txt
  4. for /f "delims=" %%i in ('type "a.txt"') do (if not defined %%i set %%i=A & echo Regsvr32/s "%%i">>"1.cmd")
复制代码
结果:
  1. Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AddrSearch.dll"
  2. Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AFCtrl.dll"
  3. Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AFUtil.dll"
  4. Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AppCom.dll"
  5. Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AppFramework.dll"
  6. Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AppMisc.dll"
  7. Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AppUtil.dll"
  8. Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\AuCommon.dll"
  9. Regsvr32/s "D:\Documents and Settings\Administrator\桌面\Tencent\QQ\Bin\audioengine.dll"
  10. ... ...
复制代码
我希望得到的结果:
  1. Regsvr32/s "Bin\XVEngine.dll"
  2. Regsvr32/s "Bin\AddrSearch.dll"
  3. Regsvr32/s "Bin\AFCtrl.dll"
  4. Regsvr32/s "Bin\AFUtil.dll"
  5. Regsvr32/s "Bin\AppCom.dll"
  6. Regsvr32/s "Bin\AppFramework.dll"
  7. Regsvr32/s "Bin\AppMisc.dll"
  8. Regsvr32/s "Bin\AppUtil.dll"
  9. ... ...
复制代码
谢谢!
1

评分人数

    • Batcher: 感谢给帖子标题标注[已解决]字样PB + 2

本帖最后由 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

谢谢!
已达到预期效果(问题出在重复执行了一遍一楼的代码)

TOP

  1. @echo off&setlocal enabledelayedexpansion
  2. title=  查找包含.dll .ax字符行
  3. for /f "delims=" %%i in ('dir/b/s/a-d "%~dp0Bin\*.dll"') do echo %%i>>a.txt
  4. for /f "delims=" %%i in ('type "a.txt"') do (
  5.    if not defined %%i set %%i=A & echo Regsvr32/s "Bin\%%~nxi">>"1.cmd"
  6. )
复制代码
1

评分人数

TOP

用%%~nxi代替%%i
zm900612 发表于 2011-5-16 23:14

谢谢!

我试了,没成功,请帮忙贴上完整的代码

TOP

用%%~nxi代替%%i

TOP

返回列表