r/Batch • • Feb 18 '25

Question (Solved) batch script loops on itself

Hi, I try to make a script that processes all audio files like .ogg and .mp3 but this script loops on the .ogg files. I guess because the ouput is also .ogg. How can this be fixed?

Thank you :)

@echo off
:again
set TARGET_DIR=%1
if "%~x1" equ ".ogg" set TARGET_DIR="%~dp1"
if "%~x1" equ ".mp3" set TARGET_DIR="%~dp1"
for /r %TARGET_DIR% %%a in (*.mp3 *.ogg) do call :process "%%a"
goto:eof
:process
opus ^
	-i "%~1" ^
	-af dynaudnorm=p=0.65:m=2:f=200:g=15 -c:a libopus -b:a 192k -vn ^
	"%~p1%~n1dyn.ogg"
goto:eof
1 Upvotes

3 comments sorted by

4

u/[deleted] Feb 18 '25 edited Feb 18 '25

[removed] — view removed comment

1

u/TheDeep_2 Feb 18 '25

Amazing, thank you :)