.bat在子文件夹中运行所有.bat [英] .bat to run all .bat in a sub folder

查看:1027
本文介绍了.bat在子文件夹中运行所有.bat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个批处理文件(run.bat)以执行名为execute的子目录中的所有文件.

I would like to create a batch file (run.bat) to execute all files in a sub dir called execute.

我在这里看到了一些示例,但尚未成功根据我的要求自定义它们.

I have seen a few examples on here but haven't succeeded in customising them for my requirements.

run.bat,它的子文件夹可能在任何地方.因此,需要一个相对的文件夹引用.

run.bat, and its sub folder might be anywhere. So a relative folder reference is needed.

例如

  • c:\ somelocation \包含run.bat
  • c:\ somelocation \ execute \包含我要运行的所有其他批处理文件

能够以30秒的间隔启动它们也很棒.

It would be great too to be able to start them at 30 second intervals.

.bat编程对我来说完全陌生,因此将不胜感激.

.bat programming is totally foreign to me so any help will be appreciated.

推荐答案

@echo off
pushd c:\somelocation\execute
for /f "delims=" %%x in ('dir /b /a-d *.bat') do start "" "%%x"&timeout /t 30 >nul
popd

应该完成工作.切换到该位置,执行每个.bat文件,在启动每个文件后等待30秒.

should get the job done. Switch to the location, execute each .bat file, wait 30 seconds after launching each one.

是的,应该是timeout而不是choice.对于choice,它需要参数/t 30 /d y

Edit : yes, should be timeout not choice. With choice, it needs parameters /t 30 /d y

这篇关于.bat在子文件夹中运行所有.bat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆