从另一个文件夹运行批处理文件

从另一个文件夹运行批处理文件

包含批处理文件的文件夹和包含将要标准化的音频文件的文件夹位于桌面上。

当我将包含批处理文件的文件夹移动到另一个位置(例如 D:\)并运行该批处理文件时,它说未找到桌面文件夹中的音频文件。

当批处理执行 FOR 命令读取桌面文件夹中的音频文件时,批处理将取消:

FOR /F "delims=" %%a in ('dir /b *.flac ^|find /v /i "_LOUDNORM" ^|find /v /i "_EBU"') DO

我尝试根据以下链接中的信息更改 FOR 命令,放置桌面文件夹的绝对路径,但即便如此,该命令仍找不到该文件:

命令提示符目录 b

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
)

答案1

你可以试试:

@echo off

pushd "%Userprofile%\Desktop\Audios to convert"
for /f delimsˆ= %%a in ('where .:*.flac ^|findstr /vi "_loudnorm  _ebu"')do ...
popd 

相关内容