-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMP3extractor.sh
More file actions
executable file
·248 lines (233 loc) · 8.74 KB
/
MP3extractor.sh
File metadata and controls
executable file
·248 lines (233 loc) · 8.74 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
#!/bin/bash
#################################################################################
# Sezione Variabile colori #
#################################################################################
und=$(tput smul) # attiva il sottolineato
nound=$(tput rmul) # disattiva il sottolineato
bold=$(tput bold) # attiva il grassetto
rev=$(tput rev) # attiva la modalità inversa
# (scambia sfondo e carattere)
normal=$(tput sgr0) # annulla tutti gli effetti e torna al default
tred=$(tput setaf 1) # carattere rosso
tgreen=$(tput setaf 2) # carattere verde
tyellow=$(tput setaf 3) # carattere giallo
tblue=$(tput setaf 4) # carattere blu
tpurple=$(tput setaf 5) # carattere porpora
tcyan=$(tput setaf 6) # carattere ciano (azzurro)
twhite=$(tput setaf 7) # carattere bianco
bred=$(tput setab 1) # sfondo carattere rosso
bgreen=$(tput setab 2) # sfondo carattere verde
byellow=$(tput setab 3) # sfondo carattere giallo
bblue=$(tput setab 4) # sfondo carattere blu
bpurple=$(tput setab 5) # sfondo carattere porpora
bcyan=$(tput setab 6) # sfondo carattere ciano (azzurro)
bwhite=$(tput setab 7) # sfondo carattere bianco
################################################################################
clear
######################## MAIN VARIABLES ####################
version="v1.0"
NameOutput="FileMp3"
folfInput=""
foldOutput=""
github="https://github.com/SimoLinuxDesign/MP3Extractor.git"
userdev="SimoLinuxDesign"
############################################################
################### DESCRIPTION PROGRAM ####################
echo "#####################################################"$bblue
echo " "
echo " Welcome in MP3 extractor! "
echo " "$normal
echo "#####################################################"$bcyan
echo " "
echo " Welcome to the MP3-Extractor $version. "
echo " Follow all the guided procedure to extract all mp3 "
echo " from one folder to another. "
echo " You can select your input and output folder during "
echo " the process. "
echo " "$normal
echo "-----------------------------------------------------"$bblue
echo " For more information, check the GitHub Repository: "
echo $tpurple$bold"$github "$normal$bblue
echo " Developer:$tgreen$userdev "$normal
echo "#####################################################"
echo "Press 'Enter' to continue"
read continue
clear
############################################################
################# KBPS TABLE #######################
echo "#################################################"
echo " Select the kbps that you want to use to convert"
echo "#################################################"
echo ""
echo $tgreen" 1 = 96k"$normal
echo $tblue" 2 = 128k "$normal
echo $tcyan" 3 = 192k "$normal
echo $tyellow" 4 = 256k "$normal
echo $tpurple" 5 = 320k "$normal
echo $tred" q = Quit Program"$normal
echo ""
echo "#################################################"
echo ""
########################################################
################### KBPS SELECTION #####################
kbps=0
while [ "$kbps" != "1" ] && [ "$kbps" != "2" ] && [ "$kbps" != "3" ] && [ "$kbps" != "4" ] && [ "$kbps" != "5" ] && [ "$kbps" != "q" ];
do
read kbps
case $kbps in
1)
kbpsDone="96k"
sel1=$tgreen"96kbps"$normal
echo $sel1
;;
2)
kbpsDone="128k"
sel1=$tblue"128kbps"$normal
echo $sel1
;;
3)
kbpsDone="192k"
sel1=$tcyan"192kbps"$normal
echo $sel1
;;
4)
kbpsDone="256k"
sel1=$tyellow"256kbps"$normal
echo $sel1
;;
5)
kbpsDone="320k"
sel1=$tpurple"320kbps"$normal
echo $sel1
;;
"q")
echo "Quit program selected"
exit
;;
*)
echo "Wrong button pressed"
;;
esac
done
########################################################
######################## HZ TABLE ######################
clear
echo "#############################################"
echo "$sel1"
echo "#############################################"
echo "Select the hz that you want to use to convert"
echo "#############################################"
echo ""
echo $tgreen"1 = 8000hz "
echo $tblue"2 = 11025hz "
echo $tcyan"3 = 22050hz "
echo $tyellow"4 = 44100hz "
echo $tpurple"5 = 48000hz "
echo $tred"q = Quit Program$normal "
echo ""
echo "#############################################"
########################################################
##################### HZ SELECTION #####################
echo ""
hz=0
while [ "$hz" != "1" ] && [ "$hz" != "2" ] && [ "$hz" != "3" ] && [ "$hz" != "4" ] && [ "$hz" != "5" ] && [ "$hz" != "q" ];
do
read hz
case $hz in
1)
hzDone="8000"
sel2=$tgreen"8000hz"$normal
echo $sel2
;;
2)
hzDone="11025"
sel2=$tblue"11025hz"$normal
echo $sel2
;;
3)
hzDone="22050"
sel2=$tcyan"22050hz"$normal
echo $sel2
;;
4)
hzDone="44100"
sel2=$tyellow"44100hz"$normal
echo $sel2
;;
5)
hzDone="48000"
sel2=$tpurple"48000hz"$normal
echo $sel2
;;
"q")
echo "Quit program selected"
exit
;;
*)
echo "Wrong button pressed"
;;
esac
done
clear
########################################################
#################### SHOW SELECTION ####################
echo $tyellow"#############################################"$normal
echo " $sel1 has been selected. "$normal
echo $tyellow"#############################################"$normal
echo " $sel2 has been selected. "$normal
echo $tyellow"#############################################"$normal
########################################################
############ SELECT INPUT FOLDER WITH CHECK ############
while true; do
echo $bold$tcyan"Write the path from where you want to get all your mp4 files:$normal$tblue"
read foldInput
if [ -n "$(find "$foldInput" -maxdepth 1 -type f -name '*.mp4' -print -quit)" ]; then
clear
echo $normal"-----------------------------------------------------------------------------"
echo $tgreen$bold"Mp4 files founds in: $twhite $foldInput"$normal
echo $normal"-----------------------------------------------------------------------------"
break
else
clear
echo $normal"--------------------------------------------------------------------------------------------------"
echo $tred$bold"There is not any MP4 files in the folder:$normal $foldInput$bold$tred. Try again"$normal
echo "--------------------------------------------------------------------------------------------------"$normal
fi
done
cd $foldInput
##############################################################
################### SELECT OUTPUT FOLDER #####################
echo "####################################################################"
echo $bold$tpurple"Write the path where you wish bring all your mp4 files:$normal$tblue"
read foldOutput
echo "$normal"
clear
############################################################
#################### SHOW SELECTION 2 ######################
echo $tyellow"#############################################"$normal
echo "$sel1 has been selected. "$normal
echo $tyellow"#############################################"$normal
echo "$sel2 has been selected. "$normal
echo $tyellow"#############################################"$normal
echo "Input mp4 folders:$tblue$bold$foldInput"$normal
echo $tyellow"#############################################"$normal
echo "Output mp3 folders:$tpurple$bold$foldOutput"$normal
echo $tyellow"#############################################"$normal
###########################################################
################## START EXTRACTION #######################
for i in *.mp4; do
ffmpeg -i "$i" -ab ${kbpsDone} -ar ${hzDone} "$(basename "$i" .mp4)".mp3
done
clear
read -p $tbold$tgreen"Extraction Done!$normal Press 'enter' to continue... " continue
###########################################################
############### MOVING EXTRACTED FILES ####################
test -d $foldOutput || mkdir -p $foldOutput && mv *.mp3 $foldOutput
###########################################################
##################### FINISH OPERATIONS ###################
clear
echo $bold$tgreen"Operation Completed!"$normal
echo "You can find all the filse to this path:"
echo $tpurple"$foldOutput"$normal$bold
read -p "Press 'Enter' to close the program!" continua
exit 0