-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwavToMp3.cmd
More file actions
51 lines (40 loc) · 1.17 KB
/
wavToMp3.cmd
File metadata and controls
51 lines (40 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@echo off
echo ###################################################
echo # Description: Convert WAV to MP3 format
echo # Usage: wavToMp3.cmd /path/to/audio.wav [192]
echo # Param 1: Audio file or directory
echo # Param 2 [Optional]: Bitrate in kbps (default: 320)
echo # Requires: ffmpeg
echo ###################################################
echo.
REM Check parameters
IF "%~1"=="" (
echo Error: 1st arg must be an audio file or directory
exit /b 1
)
REM Set defaults
set "bitrate=320"
IF NOT "%~2"=="" set "bitrate=%~2"
echo [Optional]: Using bitrate of %bitrate%kbps
REM Check if input is a directory
IF EXIST "%~1\" (
echo Processing directory: %~1
REM Loop through wav files in directory
FOR %%i IN ("%~1\*.wav") DO (
CALL :ProcessFile "%%i" %bitrate%
)
echo Success: Converted files in: %~1
) ELSE (
CALL :ProcessFile "%~1" %bitrate%
)
exit /b 0
:ProcessFile
REM Process a single audio file
set "filename=%~1"
set "bitrate=%~2"
set "outputFile=%~dpn1.mp3"
echo Converting: %filename% to MP3 at %bitrate%kbps
REM Do conversion
ffmpeg -i "%filename%" -ab %bitrate%k "%outputFile%"
echo Success: Created MP3: %outputFile%
exit /b 0