@echo off setlocal enabledelayedexpansion :: Change directory to where prepared_steps is located cd ..\..\prepared_steps :: Loop through all folders in prepared_steps for /d %%f in (*.*) do ( set "current_dir=%%f" :: Check if command.txt exists in the current folder if exist "%current_dir%\command.txt" ( echo Running command from %current_dir% :: Read the command from command.txt and execute it for /f %%c in ('type "%current_dir%\command.txt"') do ( start "" "%%c" ) :: Pause after each command to see results pause ) else ( echo No command.txt found in %current_dir% ) ) :: Exit the script goto :EOF