标题: [文件操作] 批处理怎样提取文件的完整路径? [打印本页]
作者: 1e3e 时间: 2012-2-26 22:14 标题: 批处理怎样提取文件的完整路径?
如:
C:\WINDOWS\inf\AER_1041.ADM
C:\WINDOWS\inf\AER_1042.ADM
C:\WINDOWS\inf\AER_2052.ADM
C:\WINDOWS\inf\AER_3082.ADM
C:\WINDOWS\WinSxS\Manifests\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd.cat
C:\WINDOWS\WinSxS\Manifests\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd.manifest
C:\WINDOWS\WinSxS\Manifests\x86_System.EnterpriseServices_b03f5f7f11d50a3a_2.0.0.0_x-ww_7d5f3790.manifest
C:\WINDOWS\WinSxS\Policies\x86_policy.8.0.Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_x-ww_77c24773\8.0.50727.42.cat
C:\WINDOWS\WinSxS\Policies\x86_policy.8.0.Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_x-ww_77c24773\8.0.50727.42.policy
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd\msvcm80.dll
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd\msvcp80.dll
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd\msvcr80.dll
C:\WINDOWS\Installer\29000.msi
C:\WINDOWS\Microsoft.NET\Framework\NETFXSBS10.exe
C:\WINDOWS\Microsoft.NET\Framework\netfxsbs12.hkf
C:\WINDOWS\Microsoft.NET\Framework\sbs_diasymreader.dll
C:\WINDOWS\Microsoft.NET\Framework\sbs_iehost.dll
提取到:
C:\WINDOWS\inf\
C:\WINDOWS\WinSxS\Manifests\
C:\WINDOWS\WinSxS\Policies\x86_policy.8.0.Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_x-ww_77c24773
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_0de06acd
C:\WINDOWS\Installer
C:\WINDOWS\Microsoft.NET\Framework
输出为1.txt
作者: apang 时间: 2012-2-26 22:28
- @echo off
- for /f "delims=" %%a in ( test.txt) do (
- if not defined %%~dpa echo %%~dpa&set "%%~dpa=%%~dpa"
- )
- pause
复制代码
作者: 1e3e 时间: 2012-2-26 22:35
apang 发表于 2012-2-26 22:28
怎样把结果输出为1.txt呢?
作者: apang 时间: 2012-2-26 22:49
本帖最后由 apang 于 2012-2-26 22:50 编辑
回复 3# 1e3e - @echo off
- (for /f "delims=" %%a in (test.txt) do (
- if not defined %%~dpa echo %%~dpa&set "%%~dpa=%%~dpa"
- ))>1.txt
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |