Computer Hope
Microsoft => Microsoft DOS => Topic started by: Blisk on April 25, 2014, 03:23:56 AM
-
I have to try to run all batch files under folder subfolder wih one batch
I tried this bot not working
for /d /r %%i in (D:\myfloder\Drivers\conf\) do if exist "%%i\copylog.bat" start /wait call "%%i\copylog.bat"
bat file which must be runed is under D:\myfloder\Drivers\conf\MIKE\archive\bat
I tried to run batch files from other topic
-
This will launch each batch file in that folder:
@echo off
cd /d "D:\myfloder\Drivers\conf"
for %%a in (*.bat) do call "%%a"
pause
-
Just make sure foxidrive's file isn't in D:\myflder\Drivers\conf or you will enter an infinite loop. Here is a workaround.
@echo off
cd /d "D:\myfloder\Drivers\conf"
for /f "delims=" %%A in ('dir /b *.bat ^| find /v "%~nx0"') do echo call "%%A"
echo.
echo All done.
pause
Proof of concept:
@echo off
echo Before:
echo %time%
for %%a in (*.bat) do echo call "%%a"
echo %time%
echo.
echo After:
echo %time%
for /f "delims=" %%A in ('dir /b *.bat ^| find /v "%~nx0"') do echo call "%%A"
echo %time%
echo.
echo All done.
pause>nul
T:\>findAllBat
Before:
9:43:12.28
call "colorsd.bat"
call "colorText.bat"
call "countLines.bat"
call "findAllBat.bat"
call "note.bat"
call "realtime.bat"
call "snakeV1.bat"
call "spaces.bat"
call "test.bat"
9:43:12.29
After:
9:43:12.30
call "colorsd.bat"
call "colorText.bat"
call "countLines.bat"
call "note.bat"
call "realtime.bat"
call "snakeV1.bat"
call "spaces.bat"
call "test.bat"
9:43:12.37
All done.
-
lemonilla thanks but not working.
file not found
-
This will launch each batch file in that folder:
@echo off
cd /d "D:\myfloder\Drivers\conf"
for %%a in (*.bat) do call "%%a"
pause
here nothing happends
-
Are your batch files in this folder: D:\myfloder\Drivers\conf
-
Are your batch files in this folder: D:\myfloder\Drivers\conf
no there must be batch which runs all batch files
batch files are under
D:\myfloder\Drivers\conf\MIKE\archive\bat
but all folders are diferend because are from differend usernames, this one is for MIKE.
and there is 30 users and 30 folders which have 30 batch files which needs to be runned
-
:P
-
no there must be batch which runs all batch files
batch files are under
D:\myfloder\Drivers\conf\MIKE\archive\bat
but all folders are diferend because are from differend usernames, this one is for MIKE.
and there is 30 users and 30 folders which have 30 batch files which needs to be runned
Then you got your first code example completely backwards as your code is looking for all the batch files in that folder.
D:\myfloder\Drivers\conf\)
-
Hmm,
If there are 30 users how are we doing to know which one is logged in for the correct directory path?
-
Hmm,
If there are 30 users how are we doing to know which one is logged in for the correct directory path?
this is runned on server
and I need to run this batch files
@echo off
pushd "..\logfiles"
for /f "delims=" %%a in ('dir /b /od /a-d ') do set "lastest_file=%%a"
copy "%lastest_file%" "..\test\new"
popd
-
"Runned is not a word."
Does your browser not have spell check.
Nor does your reply answer my question.
-
"Runned is not a word."
Does your browser not have spell check.
Nor does your reply answer my question.
Don't know what you mean with user logged on?
Because it is not relevant for this batch files.
We need to search copy.bat files in subfolders
D:\myfloder\Drivers\conf
and after that script will find copy.bat under
D:\myfloder\Drivers\conf\MIKE\archive\bat
D:\myfloder\Drivers\conf\JOE\archive\bat
D:\myfloder\Drivers\conf\NIKE\archive\bat
and it will run that copy.bat files
-
So you said 30 folders with 30 batch files. That is 900 batch files. You really want to execute 900 batch files?
-
I have no idea what you are trying to accomplish. But this is my take on it.
for /d %%G in (D:\myfloder\Drivers\conf\*) do (
FOR %%H in ("%%G\archive\bat\*.bat") do call "%%H"
)
-
You really want to execute 900 batch files?
Remember that guy who had a 15,000 line batch a few months ago? Or was it 1500?
-
Remember that guy who had a 15,000 line batch a few months ago? Or was it 1500?
yeah, because his code was redundant and he didn't bother to use a loop.
-
It helps when you get accurate/full information. +1 to Patio.