-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmusconv
executable file
·49 lines (43 loc) · 897 Bytes
/
musconv
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
#!/usr/bin/env rc
fn sane{
printf '%s\n' $1 |
tr 'A-Z' 'a-z' |
tr ' -' '_' |
tr -d ',\[\]^!<>=&{}*?()\-:#$|~`+%"''' |
sed 's/^[0-9][0-9]//' |
sed 's/__\+/_/g' |
sed 's/^_//'
}
ifs='
'
exts=(mp3 m4a flac wav)
for(i in `{find -maxdepth 1 -type d | sed '/^\.$/d'}){
j=`{sane $i}
mv $i $j
}
for(i in `{find -maxdepth 1 -type d | sed '/^\.$/d'}){
cd $i
for(j in $exts){
for(k in `{fds . | grep -a '\.'$j'$'})
mv $k `{sane `{basename $k}}
}
cd ..
}
for(i in `{find -maxdepth 1 -type d | sed '/^\.$/d'}){
cd $i
for(j in $exts){
for(k in `{ls *.$j >[2]/dev/null}){
switch($j){
case 'mp3'
new=`{printf '%s\n' $k | sed 's/\.mp3$/.ogg/'}
ffmpeg -i $k -f 'ogg' $new
case 'm4a'
int=`{printf '%s\n' $k | sed 's/\.m4a$/.wav/'}
new=`{printf '%s\n' $k | sed 's/\.m4a$/.ogg/'}
ffmpeg -i $k -f 'wav' $int
ffmpeg -i $int -f 'ogg' $new
}
}
}
cd ..
}