使用Windows在所有目录中递归执行命令 [英] Recursively execute command in all directories using Windows
本文介绍了使用Windows在所有目录中递归执行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试执行可执行的pngout文件,以压缩文件夹及其子文件夹中包含的所有图像.我正在使用Windows 7计算机. 我尝试使用以下代码:
I'm trying to execute the executable pngout file to compress all images contained in a folder and its subfolder. I'm using a Windows 7 machine. I've tried with the following code:
for %i in (*.png) do pngout "%i" /kp
for /r /d %%x in (*) do (
pushd "%%x"
for %i in (*.png) do pngout "%i" /kp
popd
)
但是在出现此错误时出现问题:
i"/kp意外
However there is an issue as I get this error:
i" /kp Unexpected
但是在单行上执行此命令仍然有效(在当前目录上):
However executing on a single line this command it works (on the current directory):
for %i in (*.png) do pngout "%i" /kp
有指针吗? 谢谢!
推荐答案
将代码放入批处理文件中,并将%i
项更改为%%i
Put your code in a batch file and change the %i
terms to %%i
这篇关于使用Windows在所有目录中递归执行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文