嵌套FORFILES:路径和扩展名过滤器 [英] nested forfiles: path and extension filter
问题描述
是否有可能嵌套两个 forfile
命令,这样我可以通过路径过滤和延长并那么只有在那些双过滤的文件运行命令?
is there any possibility to nest two forfile
commands so that I can filter by pathname and by extension and then run a command only on those double filtered files?
作为例子我想获得所有用户的所有Outlook HTML的签名。我可以通过
By example I'd like to get all Outlook HTML-signatures of all users. I can do this by
forfiles /s /p c:\Users /m *Signatures* /c "cmd /c forfiles /s /p @path /m *.htm"
但是,这将只显示文件名,因为它是 FORFILES
的默认行为叫 CMD / C回声@file
。
更改这不起作用,因为那时我需要设置在内部的 / C
- 选项 FORFILES
命令,它需要导致双引号引号来设置命令:
Changing this doesn't work because then I'd need to set the /c
-option in the inner forfiles
command which requires to set the command in quotes resulting in double quotes:
forfiles /s /p c:\Users /m *Signatures* /c "cmd /c forfiles /s /p @path /m *.htm /c "cmd /c echo @path""
我怎么能逃脱内报价或使用一些不同的方法来运行由路径的一个子和文件扩展名筛选的所有文件的任何命令?
How can I escape the inner quotes or use some different approach to run any command on all files filtered by a substring of path and the file extension?
亲切的问候结果sc911
Kind regards
sc911
忘记 / S
递归搜索[/编辑]
[edit] forgot /s
for recursive searching [/edit]
推荐答案
FORFILES
似乎能够识别 \\
作为逃避的方式内。因此,下面应该工作:
FORFILES
seems to be able to recognise \"
as the way of escaping inner "
. So, the following should work:
forfiles /p c:\Users /m *Signatures* /c "cmd /c forfiles /p @path /m *.htm /c \"cmd /c echo @path\""
这篇关于嵌套FORFILES:路径和扩展名过滤器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!