How to Combine all Batch Files in one single batch file

Viewed 51

I use all the batch files below and they work, I use them one after the other.

what approach should I take to combine them in a single batch file?

Now I use one batch file with:
 call "file1.bat"
 call "file2.bat"
 call "file3.bat"
and so on

I have a folder with thousands of .mp4 files, all .mp4 already grouped in folders.

What my batch files already do: Start moving .mp4 files from folders into the main folder, delete the remaining empty folders. Rename .mp4 with random names so that when I group them again the content of the folders will be different. Then group the .mp4 files by 60 in folders, then those folders by 15 in other new folders. I need to choose how many mp4 files in folders and after how many folders with .mp4 inside to be grouped in other folders.

I use the following batch files in the following steps:

FIRST STEP: I move .mp4 files from folders into the main folder and delete the remaining empty folders.

@echo off
set "dest="
set "source="
for /r "%source%" %%d in (*) do move "%%d"  "%dest%"
FOR /F delims^= %%A IN ('DIR/AD/B/S^|SORT/R') DO RD "%%A"

SECOND STEP: I rename .mp4 with random names so that when I group them again the content of the folders will be different.

@echo off
set "chars=ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
for /f "eol=: delims=" %%F in ('dir /b /s /a-d *.mp4') do call :renameFile "%%F"
exit /b

:renameFile
setlocal enableDelayedExpansion
:retry
set "name="
for /l %%N in (1 1 8) do (
  set /a I=!random!%%36
  for %%I in (!I!) do set "name=!name!!chars:~%%I,1!"
)
echo if exist !name!.mp4 goto :retry
endlocal & ren %1 %name%.mp4

Third step: To be sure that .mp4 files are mixed enough I use also a count rename

@Echo off
For /f "tokens=1* delims=:" %%A in (
  'Dir /B/S/ON/A-D "*.mp4" ^|findstr /N /V "^$"'
) Do Ren "%%~fB" "%%A%%~xB"

The Fourth Step: Here I group the .mp4 files, 60 in each folder or choose as many as I need

@echo off
setlocal enabledelayedexpansion
PushD %~dp0
set "songsPeralbum=60"
set "fcount=0"
set idx=0

for /F "delims=" %%I in ('dir /a-d /o:n /b *.mp4') do (
    REM echo Processing %%I
    set /a idx=idx %% songsperalbum +1
    if !idx! equ 1 set /a fcount+=1
    md Album-!fcount! 2>nul
    move "%%I" "Album-!fcount!\"
    REM pause
)

The Fifth step: here I take all the folders containing the .mp4 files and group them in other folders. In the created folders I will add 15 or more folders.

here I need another code that automatically groups all the folders found, with the option to select how many folders to be grouped.

@Echo off
mkdir "Album-1" "Album-2" "Album-3" "Album-4" "Album-5" "Album-6" "Album-7" "Album-8" "Album-9" "Album-10" "Album-11" "Album-12" "Album-13" "Album-14" "Album-15" "Album-16" "Album-17" "Album-18" "Album-19" "Album-20" & popd 


for /D %%b in ("Album-1") do move /Y "%%~fb" "Album-1\"
for /D %%b in ("Album-2") do move /Y "%%~fb" "Album-1\"

and so on

all these 5 batch files in a single batch file, it would be great! At the same time optimized to work quickly, as I have thousands of files. thank you

1 Answers

you should use iexpress , it's a component of Windows used to create self-extracting packages from a set of files.
You just need:
-Windows
-A batch file that starts all the batch files you want to combine
-The batch files you want to combine
No need to install anything.
WARNING: SET EVERYTHING TO WORK ONLY IN THE ROOT FOLDER WITH USING ANY "CD" COMMAND, EVERYTHING NEED TO WORK ONLY IN THE FOLDER WHERE YOUR MP4 FILES ARE STORED
Steps:

  1. Search on start "iexpress"
  2. Select "Create new Self Extraction Directive file" and click "next"
  3. Select "Extract files and run an installation command" and click "next"
  4. Enter anything you want on "Package Title" and click "next"
  5. Select "No prompt" and click "next"
  6. Select "Do not display a license" and click "next"
  7. Now add these batch files: -First add the batch that opens other batch files -Now add all other batch files in the correct order And click "next"
  8. Write the name of the batch file that starts other batch files when it asks "Install Program", do not write anything in "Post Install Command", click "next"
  9. Select if showing the cmd windows or not i recommend setting to "Default", click "next"
  10. Click "next" again when it asks to set some kind of "Finished message"
  11. Click "Broswe" and give a name to the file (without any .bat or extension at the end) and select "Hide File Extracting Progress Animation from User", then click "next"
  12. Select "no restart" and click "next"
  13. Select "don't save" and click "next"
  14. Click "next"
    Done!
    Now you get a .exe files that will open all the batch files you need.
Related