Skip to content

Instantly share code, notes, and snippets.

@lightsongjs
Created December 3, 2024 09:09
Show Gist options
  • Save lightsongjs/8e50cf6d1ce55ceef9a24c83d30fe888 to your computer and use it in GitHub Desktop.
Save lightsongjs/8e50cf6d1ce55ceef9a24c83d30fe888 to your computer and use it in GitHub Desktop.
converts all .wav files in the current directory to .mp3
@echo off
:: Enable delayed expansion for dynamic variable handling
setlocal enabledelayedexpansion
:: Loop through all .wav files in the current directory
for %%f in (*.wav) do (
:: Extract the base name without extension
set "basename=%%~nf"
echo Converting "%%f" to "!basename!.mp3"
:: Use `ffmpeg` to convert the file, with overwrite enabled
ffmpeg -y -i "%%f" -codec:a libmp3lame -q:a 2 "!basename!.mp3"
:: Verify file conversion and output the converted file name
if exist "!basename!.mp3" (
echo Converted file: "!basename!.mp3"
) else (
echo Failed to convert "%%f"
)
)
echo All conversions are complete
.you
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment