home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Sound / LAME / src / mlame < prev    next >
Text File  |  2000-01-31  |  2KB  |  82 lines

  1. #!/bin/bash 
  2. #!/usr/local/bin/bash
  3. ############################################################################
  4. #   
  5. #  Run the LAME encoder on multiple files, with option to delete .wav files
  6. #  after encoding.  "mlame -h" will give instructions.
  7. #
  8. #  Robert Hegemann <Robert.Hegemann@gmx.de>
  9. #
  10. ############################################################################
  11.  
  12. mp3coder="lame"
  13. options="-h -d -m j -b 128"
  14. rmsrc=false
  15.  
  16. helptext="\
  17. \nThis script runs the LAME mp3 encoder on multiple files: \n\n\
  18. $0 [options] <file 1> ... <file n>\n\
  19. \n\
  20.   options:\n\
  21.     -h                  this help text\n\
  22.     -r                  remove files after encoding\n\
  23.     -o \"<lame options>\" overrides script default options \"${options}\"\n\
  24. \n\
  25.   example:\n\
  26.     $0 -r -o \"-v -V 0 -b 112\" a*.wav z*.aif\n\
  27.     \n\
  28. "
  29.  
  30. #   process command-line options
  31. #   this could be extended to fake the 
  32. #   commandline interface of the mp3encoder
  33.  
  34. while getopts ":o:r" optn; do
  35.     case $optn in
  36.     o ) options=$OPTARG # replace default options
  37.         ;; 
  38.     r ) rmsrc=true
  39.         ;;
  40.     \? ) printf "$helptext"
  41.         exit 1  
  42.         ;;
  43.     esac
  44. done
  45. shift $(($OPTIND - 1))
  46.  
  47. #   process input-files
  48.  
  49. for filename in "$@"; do
  50.     case $filename in
  51.     *[*?]*  )   # means shell couldn´t extend *.wav, etc.
  52.         echo "warning: no $filename file(s) found"
  53.         ;;
  54.     *[.][wW][aA][vV]  )
  55.         name=${filename%[.][wW][aA][vV]}
  56.         if $mp3coder $options "$filename" "${name}.mp3" 
  57.         then
  58.             if [ $rmsrc = true ]; then
  59.                 rm -f "$filename"
  60.             fi
  61.         fi
  62.         ;;
  63.     *[.][aA][iI][fF]  )
  64.         name=${filename%[.][aA][iI][fF]}
  65.         if $mp3coder $options "$filename" "${name}.mp3" 
  66.         then
  67.             if [ $rmsrc = true ]; then
  68.                 rm -f "$filename"
  69.             fi
  70.         fi
  71.         ;;
  72.     *   )
  73.         if $mp3coder $options "$filename" "${filename}.mp3" 
  74.         then
  75.             if [ $rmsrc = true ]; then
  76.                 rm -f "$filename"
  77.             fi
  78.         fi
  79.         ;;
  80.     esac
  81. done
  82.