38 lines
1 KiB
Batchfile
38 lines
1 KiB
Batchfile
:: .\count_mp4_minutes.bat
|
|
|
|
@echo off
|
|
setlocal EnableDelayedExpansion
|
|
|
|
set "count=0"
|
|
set "total_seconds=0"
|
|
set "output_file=mp4_list.txt"
|
|
|
|
:: Clear or create the output file
|
|
echo Listing MP4 files... > "%output_file%"
|
|
|
|
for /R %%F in (*.mp4) do (
|
|
set /a count+=1
|
|
|
|
:: Extract filename only (no path)
|
|
for %%N in ("%%~nxF") do echo %%~nxF >> "%output_file%"
|
|
|
|
for /f "delims=" %%D in ('ffprobe -v error -show_entries format^=duration -of default^=noprint_wrappers^=1:nokey^=1 "%%F"') do (
|
|
set "duration=%%D"
|
|
set "duration=!duration:.=!"
|
|
set /a seconds=!duration:~0,-6!
|
|
set /a total_seconds+=seconds
|
|
)
|
|
)
|
|
|
|
set /a total_minutes=total_seconds / 60
|
|
set /a hours=total_minutes / 60
|
|
set /a minutes=total_minutes %% 60
|
|
set /a remaining_seconds=total_seconds %% 60
|
|
|
|
echo. >> "%output_file%"
|
|
echo Total MP4 files: %count% >> "%output_file%"
|
|
echo Total duration: %hours% hours %minutes% minutes %remaining_seconds% seconds >> "%output_file%"
|
|
|
|
:: Print to screen
|
|
type "%output_file%"
|
|
pause
|