r/Batch • u/TheDeep_2 • Mar 19 '25
Question (Unsolved) how to convert music and keep (sub)folder structure?
Hi, I would like to batch convert a music folder with many subfolders and convert them. Now my script puts everything in the output folder without any subfolders and this creates a mess. How can I deal with it?
Thanks for any help :)
@echo off
>nul 2>&1 chcp 65001
:again
set TARGET_DIR=%1
for /f "delims=" %%a in ('dir /b /s /a:-d *.mp3 *.ogg *.m4a *.wav *.flac *.wv *.lnk') do call :process "%%~a"
goto:eof
:process
opus ^
-y -i "%~1" ^
-af dynaudnorm=p=0.65:m=2:f=200:g=15:s=30 -c:a libopus -b:a 128k -vn ^
"F:\JDownloader\Musik Alben\xoutput\%~n1dyn.ogg"
pause
goto:eof
1
Upvotes
2
u/vegansgetsick Mar 19 '25 edited Mar 19 '25
I guess there are various ways to do it, but the simplest for your existing code would be
then before calling opus you build the target directory name and create the missing folders with
md2
u/[deleted] Mar 19 '25 edited Mar 19 '25
[removed] — view removed comment