1

I have a parent folder (BIG_Folder), which contains many subfoldes (folder1, folder2, folder3 ...) in each subfolder a batch file exists, it is always the same (x.bat).

I want to run all bats, recursively from another bat.

BIG_Folder ( folder1 (x.bat), folder2(x.bat), folder3(x.bat) )

The folder1, folder2, folder3 are not created, created by a previous bat. For that reason, I seek to do recursively to all subfolders contained in BIG_Folder.

Attached code as I copy the bats to folders.

for /D %%f in ("C:BIG_Folder\*") do copy "C:\3.bat" "%%f\" 

Any help is appreciated

2
  • Hello! Welcome to SU, we're not a script writing service, but we can help with specific problems you may be having. What have you got so far, and where exactly are you getting stuck implementing your script? Dec 18, 2014 at 22:03
  • I got lost in this sentence: "The folder1, folder2, folder3 are not created, created by a previous bat. For that reason, I seek to do recursively to all subfolders contained in BIG_Folder." I suspect it might be a typo and it isn't obvious how recursing bat execution relates to folder creation. Can you do something with that to make it clearer?
    – fixer1234
    Dec 19, 2014 at 1:36

2 Answers 2

1

Thanks for the prompt response, I apologize for the confusion

I'll try to be brief. The goal is to package the video and audio in a file. This means that in each folder, Folder1, Folder2, Folder3, has 3 files, 1 video (VIDEO01) and 2 audio (AUDIO01) (AUDIO02). and after executing the bat (3.BAT) become one single file.

this is the precise of packing instruction

bmxtranswrap -p -t op1a --ps-avcihead -o "OUT_SingleFile" %VIDEO01% %AUDIO01% %AUDIO02%   

And this is the complete instruction of 3.bat

   @echo off 

DIR *.mxf /b /o > clips.txt

for /F "tokens=*" %%X in (clips.txt) do call :variables "%%X" 
goto fin 

:variables 
set /a contador=contador + 1 
::
if "%contador%"=="1" set linea1=%~1 
if "%contador%"=="2" set linea2=%~1 
if "%contador%"=="3" set linea3=%~1 
if "%contador%"=="4" set linea4=%~1 
if "%contador%"=="5" set linea5=%~1 

goto:eof 

:fin 

echo %linea1% 
echo %linea2% 
echo %linea3% 
echo %linea4% 
echo %linea5% 

bmxtranswrap -p -t op1a --ps-avcihead -o "OUT_%linea1%_.mxf" %linea1%  %linea2% %linea3% %linea4% %linea5%    

pause

For this reason, the bat should be in each folder. Each folder has the same bat (3.bat) but different contents of video and audio. And what I want is to execute all bat (3.bat) at time.

One thing more 1,2,3 folders are created by another bat x.bat, which scans a directory and organizes videos and audios matching characters.

    @echo off
FOR /R "C:\MATERIAL" %%a IN (*.mxf*) DO set ruta=%%a&set datos=%%~nxa&call :separar
pause
goto:eof
:separar
set copia=%datos:~0,4%
if not exist "C:\MATERIAL\CARPETAS\%copia%" MD "C:\MATERIAL\CARPETAS\%copia%"
set archivo=%datos%

if %archivo:~0,4% EQU %copia% copy "%ruta%" "C:\MATERIAL\CARPETAS\%copia%" 

echo %ruta%

goto:eof

call exe.bat

pause

There exists a second bat (2.bat) which 3.bat copy to each individual folder created by x.bat

@echo off
for /D %%f in ("C:MATERIAL\CARPETAS\*") do copy "C:\3.bat" "%%f\"
pause

Any help is appreciated

Thanks for everything

0

Executing the batch scripts is just as easy (nearly the same) as copying them there in the first place:

for /d %%F in ("c:BIG_Folder\*") do call "%%F\3.bat"

But I suspect you are asking the wrong question. There should be no reason why you must have a copy of the batch file in each folder. You should be able to have a single batch file in one location, and the script should be able to work against any folder of your choosing.

Not knowing what your batch file is supposed to do, I can't suggest what your question should be, let alone what the answer might be.

2
  • The OP never said that folder1\x.bat, folder2\x.bat, and folder3\x.bat were identical; "it is always the same (x.bat)" could mean simply "they all have the same name". Still, I agree that this is a somewhat odd configuration. Dec 18, 2014 at 22:51
  • @G-Man - The code the OP provided copies the same file to each of the directories. I suppose the file could be modified after the copy, but the way the question is presented, it implies the batch is the same in each folder.
    – dbenham
    Dec 18, 2014 at 22:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .