-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflac2mp3
More file actions
executable file
·60 lines (49 loc) · 1.6 KB
/
flac2mp3
File metadata and controls
executable file
·60 lines (49 loc) · 1.6 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# flac2mp3 - jzu@free.fr 2013 - WTFPL
# Converts FLAC files to MP3 (hq), transferring metadata in the process
# Puts MP3s in a subdirectory of ../mp3/, or a directory given by -d
# Needs flac, lame, eyeD3
# FLACs generated by "ripit -c 2 --nointeraction --comment cddbid -eject"
export LANG=C
export LC_ALL=C
ls *.flac > /dev/null || \
exit 1
export MP3DIR="../mp3/`basename \"$PWD\"`"
[ "$1" = "-d" -a -n "$2" ] && \
export MP3DIR="$2"
mkdir -p "$MP3DIR" || \
exit 2
for FLAC in *.flac
do
export MP3=`echo $FLAC \
| sed -e "s/[!']/_/g" \
-e 's/flac$/mp3/'`
export WAV=${FLAC/.flac/.wav}
flac -d "$FLAC"
lame -V 0 --vbr-new -q 0 -m s "$WAV" "$MP3DIR/$MP3"
/bin/rm "$WAV"
export GENRE="`metaflac --list "$FLAC" \
| grep "GENRE=" \
| sed "s/.*GENRE=//" \
| iconv -f UTF-8 -t ASCII//TRANSLIT`"
( metaflac --list "$FLAC" \
| grep comment\\[ \
| egrep -v 'CATE|DESC|CDID' \
| sed -e 's/.*: //' \
-e "s/'/'\\\\\\''/g" \
-e 's/TITLE=/-t "'\''/' \
-e 's/ARTIST=/-a "'\''/' \
-e 's/ALBUM=/-A "'\''/' \
-e 's/DATE=/-Y "'\''/' \
-e 's/TRACKNUMBER=/-n "'\''/' \
-e "s/GENRE=.*/-G \"'$GENRE/" \
-e 's/$/''\'\''"/' \
| xargs echo eyeD3 -2 -N `ls *.flac \
| wc -l`
echo \'$MP3DIR/$MP3\' ) \
| sed ':a;N;$!ba;s/\([^\n]\)\n/\1 /g'
done > /tmp/conv2_$$
sed 's/eyeD3 -2 /eyeD3 -1 /' < /tmp/conv2_$$ > /tmp/conv_$$
cat /tmp/conv2_$$ >> /tmp/conv_$$
sh /tmp/conv_$$
/bin/rm /tmp/conv_$$ /tmp/conv2_$$