This repository has been archived by the owner on Dec 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzogg2mp3
executable file
·79 lines (69 loc) · 2.57 KB
/
zogg2mp3
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
#!/bin/zsh
# ogg2mp3 written in zsh
# version 0.1
# Copyright 2010 Mephiston <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, get a copy on http://www.gnu.org/licenses/gpl.txt
# ---------------- Generic utilities ---------------- #
# The main purpose of this script is to easily conver OGG files into MP3 files
# Because some devices don't accept ogg format
# This script converts massively the ogg files of your actual directory
# ---------------- Instructions ---------------- #
# For using this script ou must have installed ZSH and ffmpeg
zmodload zsh/mathfunc
if [ -z "$1" ]
then
value=160
valuet=$(( ($value*1000) ))
#If bitrate is not specified will use
mensaje="Bitrate value not supplied. Default: 160kbps.\nNote: If you want to specify some specify bitrate in kbps, just write something like 'ogg2mp3 120 ''"
else
value=$1
valuet=$(( ($1*1000) ))
mensaje="Bitrate value suplied. Using $value"
fi
function capitalize {
for i in *.ogg; do
mv $i ${${(C)i}:s/Ogg/ogg/}
done
}
function removespace {
for a in ./**/*\ *(Dod);
do mv $a ${a:h}/${a:t:gs/ /_};
done
}
echo "---------------------------"
echo "| ogg2mp3 v0.1 ZSH VERSION|"
echo "| Author: Mephiston |"
echo "---------------------------"
capitalize #Now we capitalize the words with spaces between them
removespace #Now we remove spaces between the words
sleep 2
for archivo in *.ogg; do
oggname="$(basename "$archivo" .ogg)"
echo $mensaje && sleep 3 && ffmpeg -i "$oggname.ogg" -ab $valuet "$oggname.mp3"
done
#Now it checks if exists some errors.
#If all is correct delete the ogg.
if [ $? -eq 0 ]
then
clear
echo "File conversion with bitrate on $value finished\nDo you want to delete OGG files? y/n"
read respuesta;
case $respuesta in
Y|y) rm -f "$oggname.ogg";;
S|s) rm -f "$oggname.ogg";;
*) echo "The files were not deleted";;
esac
fi