- @echo off
- rem 需要ffprobe,并添加到环境变量;删除不需要的格式的代码后执行
- setlocal enabledelayedexpansion
- for /d %%d in (*) do (
- pushd "%%d"
- set /a secs=0
- for /f "delims=" %%i in ('dir /b /s /a-d *.mp4 2^>nul') do (
- for /f "tokens=2 delims=^=." %%a in ('ffprobe -show_format "%%i" 2^>^&1 ^| find "duration="') do (
- set /a secs+=%%a
- )
- )
- popd
-
- rem 格式1 总分钟数
- if not !secs! equ 0 (
- set /a m=secs/60
- ren "%%d" "%%d-!m!min"
- )
-
- rem 格式2 时分秒
- if not !secs! equ 0 (
- set /a h=secs/3600,m=secs/60%%60,s=secs%%60
- ren "%%d" "%%d-!h!h!m!m!s!s"
- )
-
- )
- endlocal & pause
复制代码
|