Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 23rd, 2012  |  syntax: None  |  size: 0.96 KB  |  hits: 3  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash                                                                    
  2. # Converts all ogg files in the current path to mp3 files.
  3. # This is useful for moving a music libary to iTunes, which doesn't support ogg
  4. find .|grep 'ogg$' > /tmp/ogg_files.txt
  5. while read line; do
  6.     basepath=$(echo $line | sed 's/.ogg$//g')
  7.     echo $basepath
  8.  
  9.     # get as much id3 tag information as possible from the path                
  10.     trackAndSong=$(basename "$basepath")
  11.     track=$(echo $trackAndSong|cut -c1-2)
  12.     song=$(echo $trackAndSong|cut -c6-)
  13.     dirname=$(dirname "$basepath")
  14.     album=$(basename "$dirname")
  15.     artistPath=$(dirname "$dirname")
  16.     artist=$(basename "$artistPath")
  17.  
  18.     sox "${basepath}.ogg" "${basepath}.wav"
  19.     # -V 2 is for high quality VBR encoding                                    
  20.     lame -V 2 --tt "${song}" --ta "${artist}" --tl "${album}" --tn "${track}" "${basepath}.wav" "${basepath}.mp3"
  21.     rm "${basepath}.wav"
  22. done < /tmp/ogg_files.txt