批处理文件执行文件夹中的所有文件
我需要一个批处理文件来启动给定文件夹中的所有文件(在本例中为 c:\macros\day)。
我已经尝试过以下操作,但似乎没有任何作用。
for /f %i in ('C:\macros\Day /b') DO command %i
I need a batch files the launches all files in a given folder (in this case it is c:\macros\day).
I've tried the following, but it doesn't seem to do anything.
for /f %i in ('C:\macros\Day /b') DO command %i
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这可以从我的命令行运行:
就像这样:
This works from my command line:
as does this:
您使用了不正确的
for
变体。只需执行(双关语)for %%i in (c:\macros\Day\*) do %%i
编辑:
如果您需要对所有文件运行
命令
:for %%i in (c:\macros\Day\*) do command %%i
You used the incorrect variant of
for
. simply do (pun intended)for %%i in (c:\macros\Day\*) do %%i
Edit:
If you need to run a
command
on all files:for %%i in (c:\macros\Day\*) do command %%i
你应该使用
dir /b
列出所有文件,所以它变成You should use
dir /b
to list all files, so it becomes另外,请确保您在批处理文件中创建变量 %%i 而不是 %i,否则您会收到“i was irreversible at this time”形式的错误。
Also, make sure that you make variables inside batch files %%i rather than %i otherwise you get an error in the form "i was unexpected at this time."
运行以下目录中的所有文件通过批处理文件的目录,每行附加文本
上面发布了一个替代方案 - 如果您愿意,可以省略尾随的“/Z /U”。
Running all files in directory via batch file with appended text on each line
An alternative is posted above - leave off the trailing "/Z /U" if you wish.
这就是我如何在与批处理文件相同的目录中运行所有 powershell 文件
This is how I could run all powershell files in same directory as the batch file