Skip to content

Instantly share code, notes, and snippets.

@AbduEhab
Last active May 4, 2023 15:12
Show Gist options
  • Save AbduEhab/4a3f21b35bd006e893f1aee48cdcd06a to your computer and use it in GitHub Desktop.
Save AbduEhab/4a3f21b35bd006e893f1aee48cdcd06a to your computer and use it in GitHub Desktop.
This is a bat file that transcodes all audio files in a directory into `.opus` files. I use this neat script to sync my `.flac` library with my mobile library.
@echo off
rem Copies the original directory structure from F:\Music to D:\Music
rem xcopy /T %1 %2
Robocopy %1 %2 /E /XF *.flac *.mp3 *.mp4
for /R %1 %%i in (*.flac;*.mp3;*.mp4) do (
rem check if file exists
if exist "%~d2%%~pni.opus" (
echo "%~d2%%~pni.opus" already exists
) else (
echo Converting "%%~fi"
rem convert to opus
ffmpeg -v quiet -i "%%~fi" -map 0:a:0 -map_metadata 0 -c:a libopus -b:a 128k -frame_duration 20 "%~d2%%~pni.opus"
)
)
echo Done
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment