Skip to content

Commit b391184

Browse files
committedDec 25, 2018
add a small flac2mp3 shell script
1 parent f33fb64 commit b391184

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
 

‎FreeBSD/flac2mp3

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
# Convert all .flac into given directory as .mp3
3+
# need flac and lame installed
4+
set -eu
5+
usage () {
6+
echo "$0 folder-to-works"
7+
exit 0
8+
}
9+
10+
loop () {
11+
for i in "${DIR}"/*.flac; do
12+
bi=$(basename -s .flac "$i")
13+
if ($1); then
14+
flac --decode --stdout "${DIR}/${bi}".flac | lame --preset extreme - "${DIR}/${bi}".mp3
15+
else
16+
echo "${bi}"
17+
fi
18+
done
19+
}
20+
21+
for i in flac lame; do
22+
if ! which -s $i; then
23+
echo "Need $i installed"
24+
exit 1
25+
fi
26+
done
27+
if [ $# -lt 1 ]; then
28+
echo "Not enought argument"
29+
usage
30+
else
31+
DIR=$1
32+
fi
33+
echo "Will convert all .flac files found into $DIR in .mp3"
34+
loop false
35+
36+
echo "Do you want to continue ? (y/n)"
37+
USER_CONFIRM=""
38+
while [ "$USER_CONFIRM" != "y" -a "$USER_CONFIRM" != "n" ]; do
39+
read USER_CONFIRM <&1
40+
done
41+
[ "$USER_CONFIRM" = "n" ] && exit 0
42+
43+
loop true

0 commit comments

Comments
 (0)
Please sign in to comment.