我一般同意其他人表达的观点 - 批处理在处理文本方面很糟糕。使用另一种语言或工具对您的任务来说是一个好主意。
但它可以用批处理来完成:-)
简单地在每个之前插入一个换行符html://
并不难
@echo off
setlocal disableDelayedExpansion
:: The first FOR loop loads a quoted linefeed into %%L
:: The blank line within the IN() clause is critical. Do not remove.
for %%L in (^"^
^") do (
for /d %%A in ("C:\Documents and Settings\*") do (
for /f "eol=: delims=" %%B in (
'findstr /S "http://" "%%A\Application Data\Sun\Java\Deployment\cache\6.0\*"'
) do (
set "line=%%B"
setlocal enableDelayedExpansion
echo(!line:http://=%%~Lhttp://!
endlocal
)
)
) >c:\temp\javaurls.txt
但是只保留以开头的结果行,http://
并在地址成为真正的痛苦之前保留每个文件的名称。
@echo off
setlocal disableDelayedExpansion
:: The first FOR loop loads a quoted linefeed into %%L
:: The blank line within the IN() clause is critical. Do not remove.
for %%L in (^"^
^") do (
for /d %%A in ("C:\Documents and Settings\*") do (
for /f "tokens=1* delims=:" %%B in (
'findstr /S "http://" "%%A\Application Data\Sun\Java\Deployment\cache\6.0\*"'
) do (
set "line=%%C"
setlocal enableDelayedExpansion
set "line=!line:http://=%%~Lhttp://!"
for /f "delims=" %%D in (
'"cmd /v:on /c echo(^!line^!|findstr http://"'
) do (
if "!!" equ "" endlocal
echo %%B: %%D
)
)
)
) >c:\temp\javaurls.txt
exit /b