]> www.hackdaworld.org Git - my-code/mp3db.git/blob - make_mp3dbcompat
initial checkin of first beta mp3db
[my-code/mp3db.git] / make_mp3dbcompat
1 #!/bin/sh
2
3 for i in *; do
4         if [ -d $i ]; then
5                 echo "renaming content of $i ..."
6                 cd $i
7                 for j in *; do
8                 if [ -f "$j" ]; then
9                         dst_file="`echo $j | sed 's/\ /\\ /g' | sed 's/(/\\(/g' | sed s'/)/\\)/g' | sed 's/&/\\&/g' | sed 's/!/\\!/g'`"
10                         trg_file="`echo $j | sed 's/\ /_/g' | sed 's/&/_/g'| sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ()-,!/abcdefghijklmnopqrstuvwxyz_____/'`"
11                         if [ "$dst_file" != "$trg_file" ]; then
12                                 mv "$dst_file" $trg_file
13                                 chmod 644 $trg_file
14                         fi
15                 fi
16                 # assume albums
17                 if [ -d "$j" ]; then
18                         cd $j
19                         album="`echo $j | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ()-,/abcdefghijklmnopqrstuvwxyz____/'`"
20                         for song in *; do
21                                 dst_file="`echo $song | sed 's/\ /\\ /g' | sed 's/(/\\(/g' | sed s'/)/\\)/g' | sed 's/&/\\&/g' | sed 's/!/\\!/g'`"
22                                 trg_file="`echo $song | sed 's/\ /_/g' | sed 's/&/_/g'| sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ()-,!/abcdefghijklmnopqrstuvwxyz_____/'`"
23                                 if [ ! -f ../${album}__${trg_file} ]; then
24                                         mv "$dst_file" ../${album}__${trg_file}
25                                         chmod 644 ../${album}__${trg_file}
26                                 fi
27                         done
28                         cd ..
29                         rm -rf $j
30                 fi
31                 
32                 done
33                 cd ..
34         fi
35 done
36