Friday, 27 November 2015

Batch converting .wav to .mp3

The band I play in (Sevenfold) uses Dropbox to share recordings and song words between band members. We ended up maxing out Dropbox’s free level, so I needed to consolidate some of the files. I found a bunch of .wav files that would save a bit of space if they were converted down to .mp3.

Step 1. Install ffmpeg

FFmpeg is a cross-platform tool for manipulating MPEG audio and video files. I’d previously installed it as part of supporting MP3 with Audacity by installing FFmpeg v2.2.2. If you don’t use Audacity then you could probably install the latest version instead.

Step 2. Use PowerShell

PowerShell is a nice choice to enumerate through the .wav files. It also lets me reset the file LastWriteTime (Modified) so the new files look similar to the old ones.


$files = Get-ChildItem *.wav
foreach ($f in $files) {     
& "C:\Program Files (x86)\FFmpeg for Audacity\ffmpeg.exe" -i $f.FullName -id3v2_version 3 -write_id3v1 1 C:\Users\David\Music\Sevenfold\$($f.BaseName).mp3 -y    
$destFile = Get-Item C:\Users\David\Music\Sevenfold\$($f.BaseName).mp3    
$destFile.LastWriteTimeUtc = $f.LastWriteTimeUtc }

Jon Hall has some good info about transferring the metadata as part of the conversion process (and making the metadata compatible with Windows file properties).

No comments: