我正在尝试在父文件夹folder1中有一个蝙蝠文件,这个名为run.bat的蝙蝠文件将循环遍历所有子文件夹,并并行调用一个名为child.bat的蝙蝠文件,这些child.bat将必须访问同一文件夹中的另一个文件.
I am trying to have a bat file in folder1 which is the parent folder, and this bat file which named run.bat will loop through all subfolders, and invoke a bat file named child.bat in parallel, however, these child.bat will have to access another files in the same folder.
例如:
Folder1 (have run.bat) | |_______Folder2 | | | |_______aa.txt | | | |_______child.bat | |_______Folder3 | |_______bb.txt | |_______child.bat在Folder2中的child.bat,内容为:
type aa.txt在Folder3中的child.bat,内容为:
type bb.txt我知道关于如何循环子文件夹并在子文件夹中运行bat文件已经存在问题.但是我的问题是,bat文件必须访问位于同一子文件夹中的其他文件.如果不输入子文件夹(cd subfolder),则child.bat将不会成功执行.这是我尝试过的run.bat的内容:
I know there are questions already there on how to loop though subfolders, and run bat file in subfolder. But my question is, the bat file have to access other files which located in the same child folder. and if we don't enter subfolder (cd subfolder), the child.bat will not successfully executed. Here is the content of run.bat that I tried:
@echo off for /d /r %%i in (*) do ( cd %%i start "%%i\child.bat" )但是,失败了.
有什么想法吗?
推荐答案根据您在评论中的额外信息,这应该对您有用.
Based upon your extra information in the comments, this should work for you.
@echo off FOR /d /r %%i IN (*) DO ( if exist "%%i\child.bat" start "" /d "%%i" "%comspec%" /c "child.bat" )更多推荐
循环浏览文件夹树并在子文件夹中并行执行bat文件(访问子文件夹中的文件)
发布评论