我的目录中有很多快捷方式网址。
C:\Users\Owner\Desktop\ReadItLaters>dir *.url /b
aaa.url
bbb.url
ccc.url
...
zzz.url
我想获取这些网址。 所以我写了这样的命令。
for %i in (*.url) do @type "%i" | find "URL="
输出如下。
URL=https://www.example.com/aaa.html
URL=https://www.example.com/bbb.html
URL=https://www.example.com/ccc.html
...
URL=https://www.example.com/zzz.html
味道不错。但我想获取没有“URL=”的 url 字符串。
我希望这样输出。
https://www.example.com/aaa.html
https://www.example.com/bbb.html
https://www.example.com/ccc.html
...
https://www.example.com/zzz.html
如何将“URL=”替换为空?
最佳答案
您可以使用子字符串,跳过字符串中的前 4 个字符:%_url:~4%
for /f %%i in ('type *.url^|find "URL="')do set "_url=%%~i" && call echo/%_url:<b>~4</b>%
<强> command-line
for /f %i in ('type *.url^|find "URL="')do set "_url=%~i" && call echo/%_url:<b>~4</b>%
一些进一步阅读:
[√] <强> Set
[√] <强> For Loop
[√] <强> For /F Loop
[√] <强> Conditional Execution || && ...
关于batch-file - 如何在命令提示符下修剪字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63424043/