@echo off
REM Start of Singe port to Hypseus Singe
REM Created by RHIKKI (2024) with the assistance of chatgpt
REM Modified Bladescaters script for converting mp4 to m2v & ogg)
REM Creates a txt and batch file to point to the video and run the games
REM Add the this script and mp4 file to the ffmpeg folder and run the batch file
REM To delete the mp4 video file afterwards, remove rem in front of "rem del "%%a" 
for %%a in (*.mp4) do (
    set "nom=%%~na"
    
    rem Create the "Hypseus Singe" folder if it doesn't exist
    mkdir "Hypseus Singe\singe" 2>nul
    
    rem Create a subfolder named after the MP4 file inside "singe"
    mkdir "Hypseus Singe\singe\%%~na\Video" 2>nul
    
    rem Convert video to m2v and move to "Hypseus Singe" subfolder
    ffmpeg -i "%%a" -an -qscale:v 4 -b:v 6000k -codec:v mpeg2video "Hypseus Singe\singe\%%~na\Video\%%~na.m2v"
    if %errorlevel% neq 0 (
        echo Video conversion failed for: %%a
        pause
        exit /b %errorlevel%
    )

    rem Convert audio to ogg and move to "Hypseus Singe" subfolder
    ffmpeg -i "%%a" -vn -c:a libvorbis -ar 44100 -map a -b:a 160k "Hypseus Singe\singe\%%~na\Video\%%~na.ogg"
    if %errorlevel% neq 0 (
        echo Audio track conversion failed for: %%a
        pause
        exit /b %errorlevel%
    )

    rem Create a .txt file with specific content
    (
        echo Video/
        echo 0   %%~na.m2v
    ) > "Hypseus Singe\singe\%%~na\%%~na.txt"
    
    rem Create a .bat file with specific content
    echo ..\hypseus.exe singe vldp -framefile singe\%%~na\%%~na.txt -script singe\%%~na\%%~na.singe -fullscreen -gamepad -haptic 4 -fastboot>"run_game.bat"
    ren "run_game.bat" "%%~na.bat"

    rem Move the .bat file to "batch" folder
    mkdir "batch" 2>nul
    move "%%~na.bat" "batch\%%~na.bat" >nul

    rem Move the "batch" folder into the "Hypseus Singe Mine" folder
    move "batch" "Hypseus Singe\batch" >nul

 rem   del "%%a"
)




