Untitled
unknown
plain_text
a year ago
2.9 kB
7
Indexable
@echo off
setlocal enabledelayedexpansion
echo Na grosser, ikke bins!
echo gib mal hier n pfad an und alles und dann mach ich schon
REM Prompt the user for the source directory
set /p sourceDir="PFAD VOM TRACKS ORDNER: "
REM Prompt the user for the target directory
set /p targetDir="PFAD VOM DESTINATION ORDNER: "
REM Prompt the user for the base name of the generated folders
set /p baseName="BASE NAME FÜR DIE GENERIERTEN ORDNER: "
REM Prompt the user for the number of songs per folder
set /p songsPerFolder="Anzahl der tracks pro ordner "
REM Debug: Print out the input values
echo Source Directory: %sourceDir%
echo Target Directory: %targetDir%
echo Base Name: %baseName%
echo Songs Per Folder: %songsPerFolder%
REM Check if source directory exists
if not exist "%sourceDir%" (
echo Source directory does not exist. Exiting.
pause
exit /b
)
REM Change to the source directory using pushd
pushd "%sourceDir%"
if errorlevel 1 (
echo Failed to change directory to %sourceDir%. Exiting.
pause
exit /b
)
REM Debug: Confirm current directory
echo Current Directory: %cd%
set count=0
for %%f in (*.mp3) do (
set /a count+=1
set "file[!count!]=%%f"
REM Debug: Print each file added
echo Added file: %%f
)
REM Debug: Print total count of files
echo Total number of songs: %count%
REM If no songs found, exit
if %count% equ 0 (
echo No .mp3 files found in the source directory. Exiting.
popd
pause
exit /b
)
REM Shuffle the list of songs
for /L %%i in (%count% -1 1) do (
set /a "j=%%i*%random%/(32768+1)+1"
set "temp=!file[%%i]!"
set "file[%%i]=!file[%j%]!"
set "file[%j%]=!temp!"
REM Debug: Print the shuffle swap
echo Shuffled: !file[%%i]! <-> !file[%j%]!
)
REM Change to the target directory using pushd
pushd "%targetDir%"
if errorlevel 1 (
echo Failed to change directory to %targetDir%. Exiting.
popd
popd
pause
exit /b
)
REM Create folders and move files
set folderIndex=1
set fileCount=0
for /L %%i in (1,1,%count%) do (
if !fileCount! GEQ %songsPerFolder% (
set /a folderIndex+=1
set fileCount=0
REM Debug: New folder index
echo Creating new folder index: !folderIndex!
)
set /a fileCount+=1
if not exist "%targetDir%\%baseName%_!folderIndex!" (
mkdir "%targetDir%\%baseName%_!folderIndex!"
REM Debug: Print folder creation
echo Created folder: %targetDir%\%baseName%_!folderIndex!
)
copy "%sourceDir%\!file[%%i]!" "%targetDir%\%baseName%_!folderIndex!\"
REM Debug: Print each file move
echo Moved !file[%%i]! to %targetDir%\%baseName%_!folderIndex!\
)
REM Return to the original directory
popd
popd
echo All songs have been organized.
pause
Editor is loading...
Leave a Comment