summaryrefslogtreecommitdiffstats
path: root/convert2mp3
blob: 851c7f2a8043e0b2575173b444098f0a804d8014 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
#----------------------------------------------------
# Version:      0.1.0
# Author:       Florian "Bluewind" Pritz <f-p@gmx.at>
#
# Copyright (C) 2009 Florian Pritz
#
# Licensed under GNU General Public License v3
#   (see COPYING for full license text)
#
#----------------------------------------------------
# Converts a file to an MP3 
#----------------------------------------------------

for i in "$@"; do
  pushd . &> /dev/null
  cd "$(dirname "$i")"

  file="$(basename "$i")"
  file_mp3="$(echo ${file} | sed 's/\(.*\)\..*/\1/').mp3"
  tmpfile="$(mktemp)"

  mplayer -ao pcm:fast -novideo -vc null -vo null -ao pcm:file="$tmpfile" "$file"
  lame -h "$tmpfile" "$file_mp3"
  
  rm "$tmpfile"

  popd &> /dev/null
done