forked from ruanyf/simple-bash-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkconcerter.sh
60 lines (45 loc) · 1.32 KB
/
mkconcerter.sh
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
#! /bin/bash
tput clear
echo "No Cross No Crown"
echo "www.facebook.com/moses"
echo "www.youtube.com/notyet"
tput cup 5 30
echo -e "\033[1m \033[31m Created By Moses Kamau \033[0m"
echo -e " \033[1m \033[35mNote:\033[0m This tool is used to convert videos to mp3"
read -p "Is it a single file or multiple? [single:1, multiple:2]" quantity
if [[ "${quantity}" = 1 ]];
then
read -p "Enter path to file" file
# checking if file exists or not
if [ ! -f "$file" ];
then
echo -e "\033[1m \033[31mfile doesn't exist, please check your path and try again\033[0m"
exit
else
echo "$file"
read -p "Enter path to destination: " dest
read -p "What do you want to call it?: " name
ffmpeg -i $file -vn -ar 44100 -ac 2 -ab 192k -f mp3 "${dest}/${name}".mp3
fi
elif [[ "${quantity}" = 2 ]];
then
read -p "Enter path to folder" folder
# checking if folder exists or not
if [ ! -d "$folder" ];
then
echo -e "\033[1m \033[31mdirectory doesn't exists, please check your path and try again\033[0m"
exit
else
echo "$folder"
read -p "Enter path to destination: " dest
for i in $(ls $folder);
do
name=`echo $i | cut -d'.' -f1`;
echo $name;
ffmpeg -i "$i" "${name}.mp3";
done
fi
else
echo -e "\033[1m \033[31mPlease chose a valid option next time.\033[0m"
exit
fi