包含批处理文件的文件夹和包含将被规范化的音频文件的文件夹位于桌面上。
当我将包含批处理文件的文件夹移动到另一个位置,例如 D:\ 并运行批处理文件时,它说它没有找到桌面文件夹中的音频文件。
批处理在执行将读取桌面文件夹中的音频文件的 FOR 命令时取消:
FOR /F "delims=" %%a in ('dir /b *.flac ^|find /v /i "_LOUDNORM" ^|find /v /i "_EBU"') DO
根据下面链接中的信息,我尝试更改放置桌面文件夹的绝对路径的 FOR 命令,但即使如此,该命令也找不到该文件:
FOR /F "delims=" %%a in ('dir /b C:\Users\CMG\Desktop\Audios to convert\*.flac ^|find /v /i "_LOUDNORM" ^|find /v /i "_EBU"') DO
或者
FOR /F "delims=" %%a in ('dir /b "C:\Users\CMG\Desktop\Audios to convert\*.flac" ^|find /v /i "_LOUDNORM" ^|find /v /i "_EBU"') DO
如何使批处理文件在目录 D:\ 中正常运行?
完整命令:
FOR /F "delims=" %%a in ('dir /b *.flac ^|find /v /i "_LOUDNORM" ^|find /v /i "_EBU"') DO (
SET "filename=%%~na"
ffmpeg -hide_banner -i "%%a" -af "[0:a]loudnorm=print_format=summary" -f null NUL 2> "%%~na.log"
@FOR /F "tokens=3" %%b IN ('FINDSTR /C:"Input Integrated" "%%~na.log"') DO (SET II=%%b)
@FOR /F "tokens=4" %%b IN ('FINDSTR /C:"Input True Peak" "%%~na.log"') DO (SET ITP=%%b)
@FOR /F "tokens=3" %%b IN ('FINDSTR /C:"Input LRA" "%%~na.log"') DO (SET ILRA=%%b)
@FOR /F "tokens=3" %%b IN ('FINDSTR /C:"Input Threshold" "%%~na.log"') DO (SET IT=%%b)
@FOR /F "tokens=3" %%b IN ('FINDSTR /C:"Target Offset" "%%~na.log"') DO (SET TO=%%b)
DEL "%%~na.log"
SETLOCAL ENABLEDELAYEDEXPANSION
ECHO !II! Input Integrated
ECHO !ITP! Input True Peak
ECHO !ILRA! Input LRA
ECHO !IT! Input Threshold
ECHO !TO! Target Offset
FOR /F "tokens=1,2 delims=," %%b IN ('ffprobe -v 0 -select_streams a -show_entries "stream=sample_fmt,sample_rate" -of "csv=p=0" "!filename!.flac"') DO (
ffmpeg -hide_banner -i "!filename!.flac" -af "loudnorm=linear=true:I=!_vLUF!:LRA=11:tp=!_vPEAK!:measured_I=!II!:measured_LRA=!ILRA!:measured_tp=!ITP!:measured_thresh=!IT!:offset=!TO!:print_format=summary" -c:v copy -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" -map 0:0 -c:a flac -sample_fmt:a %%b -ar:a %%c "C:\Users\%username%\Desktop\Normalizando_lufs\!filename!.flac"
)
ENDLOCAL
)
你可以试试: