Updated 2015-10-12 02:30:23 by RLE

Last monday, I bought an MP3 player for 15 EUR. At that price, I could'nt resist. But it cannot play the *.ogg files which I copied from my Leon Redbone CD.

Converting to *.mp3 is done by the tool ffmpeg as follows:
 ffmpeg -i song.ogg song.mp3

But the file names are much longer so I prefer this quick'n'dirty script ogg2mp3:
 #! /usr/bin/tclsh
 
 proc ogg2mp3 {} {
     foreach fileName [lsort [glob -nocomplain *.ogg]] {
         set rootName [file rootname $fileName]
         set rootName1 [string map [list " " _ / -] $rootName]
         if {![file exists $rootName.mp3]} then {
             set err ""
             puts "converting $rootName ..."
             catch {exec ffmpeg -i $rootName.ogg $rootName1.mp3} err
             puts $err
         }
     }
 }
 
 ogg2mp3

AMG: In most shells you can also type:
 ffmpeg -i song.{ogg,mp3}

This avoids the need to type the song name twice.

AMG: I found another "ogg2mp3" Tcl script: http://silmor.de/6/image/ogg2mp3