Reputation: 1
I would like to make a generic script that runs every CMD-file on several subfolders. E.g.
Each subfolder contains 1 CMD file (name is not the same). It's not the same subfolders each time c:\folder\Folder1 c:\folder\folder2 c:\folder\folder3 etc
So I would like to search all subfolders and run all CMD-files on each subfolder.
Upvotes: 0
Views: 66
Reputation: 56155
for /f %%a in ('dir /s /b *.cmd') do call %%a
dir /s /b *.bat
builds a list of all cmd files
To run all those files in parallel, replace call
with start
Upvotes: 0
Reputation: 41224
This is designed to:
1) look for every .bat file in a tree
2) change to each directory with a batch file, in turn
3) run the .bat file in the folder it is in
@echo off
for /r %%a in (*.bat) do (
pushd "%%~dpa"
call "%%a"
popd
)
If you want to run every .bat file in the tree on every folder:
@echo off
for /r %%a in (*.bat) do (
for /d /r %%b in (*) do (
pushd "%%b"
call "%%a"
popd
)
)
Upvotes: 1