Skip to content

Commit 2d81ebc

Browse files
committed
Improvements
1 parent 2628be0 commit 2d81ebc

File tree

8 files changed

+87
-55
lines changed

8 files changed

+87
-55
lines changed

BeeMoved.mp3

-2.15 MB
Binary file not shown.

Sample_BeeMoved.flac

-15.9 MB
Binary file not shown.

Sample_BeeMoved.mp3

-2.15 MB
Binary file not shown.

convert.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
function convertFlacToMp3 {
4+
5+
#Crop the name of the file (without the extension).
6+
7+
croppedName=$(echo $1 | awk -F\. '{print $1}')
8+
9+
ffmpeg -i $1 -ab 320k -map_metadata 0 -id3v2_version 3 $croppedName.mp3
10+
}
11+
12+
function convertOggToMp3 {
13+
14+
#Crop the name of the file (without the extension).
15+
16+
croppedName=$(echo $1 | awk -F\. '{print $1}')
17+
18+
# If selected file is ogg, first decrypt to wav and the encryp to mp3.
19+
20+
ffmpeg -i $1 $croppedName.wav
21+
22+
ffmpeg -i $croppedName.wav -vn -ar 44100 -ac 2 -ab 192k -f mp3 $croppedName.mp3
23+
}
24+
25+
26+
# Display message with option to cancel.
27+
28+
dialog --title "Mp3 Converter" --msgbox "Please press <enter> to see audio files in the current directory or <Esc> to cancel." 10 30
29+
30+
if [ "$?" != "0" ]
31+
then
32+
33+
# Display an info message.
34+
35+
dialog --title "Mp3 Converter" --msgbox "Action was canceled at your request." 10 30
36+
else
37+
38+
#Fetch audio files in the current directory to a list.
39+
40+
let j=1
41+
for i in $(ls .)
42+
do
43+
if [ $(file $i | grep [aA]udio | awk 'BEGIN {FS=":"} {print $1}') ];
44+
then
45+
list+=("$(file $i | grep [aA]udio | awk 'BEGIN {FS=":"} {print $1}')")
46+
list+=($j)
47+
let j++
48+
fi
49+
done
50+
51+
52+
# Display a menu box and assign selection to a variable.
53+
54+
selectedItem=$(dialog --stdout --title "Mp3 Converter" --menu "Choose a file:" 10 30 3 \ ${list[@]})
55+
56+
57+
# If selected file is ogg, convert it to mp3.
58+
59+
if [ $(echo $selectedItem | grep ogg$) ];
60+
then
61+
convertOggToMp3 $selectedItem
62+
63+
if [ "$?" = "0" ]
64+
then
65+
dialog --title "Mp3 Converter" --msgbox "File successfully converted. Press <Enter> to exit" 10 30
66+
fi
67+
68+
69+
# If selected file is flac, convert it to mp3.
70+
71+
elif [ $(echo $selectedItem | grep flac$) ];
72+
then
73+
convertFlacToMp3 $selectedItem
74+
75+
if [ "$?" = "0" ]
76+
then
77+
dialog --title "Mp3 Converter" --msgbox "File successfully converted. Press <Enter> to exit" 10 30
78+
fi
79+
80+
81+
# Display an info box.
82+
83+
else
84+
dialog --title "Mp3 Converter" --msgbox "Action failed. Press <Enter> to exit" 10 30
85+
fi
86+
fi
87+
clear

example.ogg

-1.14 MB
Binary file not shown.

example.wav

-9.14 MB
Binary file not shown.

example1.mp3

-1.24 MB
Binary file not shown.

project.sh

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)