Register now and start sharing your code snippets.
-->

Converting WMA files to MP3 on Linux

Shell Script (Bash) posted 10 months ago by marko

Use this to convert WMA files to MP3 in Linux.

   1  #!/bin/bash
   2  # By Marko Haapala
   3  # converts wma to mp3 recursively. does not delete any static files, so 
   4  # cleanup and renaming is needed afterwards. 
   5  #
   6  # requirements:
   7  # lame    - http://lame.sourceforge.net/download.php
   8  # mplayer - apt-get install mplayer or http://www.mplayerhq.hu/design7/dload.html
   9  
  10  
  11  current_directory=$(pwd)
  12  wma_files=$(find "${current_directory}" -type f -iname "*.wma")
  13  # Need to change IFS or files with filenames containing spaces will not
  14  # be handled correctly by for loop
  15  IFS=$'\n' 
  16  for wma_file in ${wma_files}; do 
  17  	mplayer -vo null -vc dummy -af resample=44100 \
  18  	-ao pcm -ao pcm:waveheader "${wma_file}" && lame -m s \
  19  	audiodump.wav -o "${wma_file}".mp3
  20  	rm audiodump.wav
  21  done

Tagged wma, mp3, convert script, bash