本帖最后由 77七 于 2023-8-7 00:50 编辑
回复 23# qd2024
- @echo off
- chcp 65001 >nul
- rem 批处理保存为utf-8编码格式,需要ffmpeg ffprobe,自行修改相关路径
- for /f "delims=" %%i in ('dir /b /s /a-d *.mp3') do (
- setlocal enabledelayedexpansion
- ffprobe -loglevel 0 -show_streams "%%i" |findstr /xc:"bit_rate=128000" 1>nul || set str1=-ab 128k
- ffprobe -loglevel 0 -show_streams "%%i" |findstr /xc:"sample_rate=44100" 1>nul || set str2=-ar 44100
- if not defined str1 if not defined str2 (
- ver >nul
- ) else (
- ffmpeg -i "%%i" !str1! !str2! "xxx.mp3"
- move /y "xxx.mp3" "%%i"
- )
- endlocal
- )
- pause
复制代码 20230807 修改一下 if not if not 这个不太规范,逻辑可能有时候会出问题。
- @echo off
- chcp 65001 >nul
- rem 批处理保存为utf-8编码格式,需要ffmpeg ffprobe,自行修改相关路径
- for /f "delims=" %%i in ('dir /b /s /a-d *.mp3') do (
- setlocal enabledelayedexpansion
- ffprobe -loglevel 0 -show_streams "%%i" |findstr /xc:"bit_rate=128000" 1>nul || set str1=-ab 128k
- ffprobe -loglevel 0 -show_streams "%%i" |findstr /xc:"sample_rate=44100" 1>nul || set str2=-ar 44100
- if "!str1!!str2!" neq "" (
- ffmpeg -i "%%i" !str1! !str2! "xxx.mp3"
- move /y "xxx.mp3" "%%i"
- )
- endlocal
- )
- pause
复制代码
|