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