-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanfn
executable file
·73 lines (69 loc) · 1.39 KB
/
cleanfn
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
#!/bin/bash
# Cleans up all filenames in the directory.
# Can give optional dir.
if [ "$#" == 0 ]
then
dir="."
else
dir="$1"
fi
for i in "$dir"/*
do
#echo "ezafile: $i"
pathname=${i%/*}
fn=${i##*/}
if [ -f "$i" ]
then
newfn=`echo "$fn"|iconv -f utf-8 -t ascii//translit`
newfn=${newfn// /_}
newfn=${newfn//\'/_}
newfn=${newfn//\`/_}
newfn=${newfn//(/_}
newfn=${newfn//)/_}
newfn=${newfn//[/_}
newfn=${newfn//]/_}
newfn=${newfn//!/_}
newfn=${newfn//&/_}
newfn=${newfn//+/_}
newfn=${newfn//:/_}
newfn=${newfn//;/_}
newfn=${newfn//\"/_}
newfn=${newfn//,/_}
newfn=${newfn//\?/_}
newfn=${newfn//=/_}
newfn=${newfn//%/_}
newfn=${newfn//#/_}
# newfn=${newfn//\á/a}
# newfn=${newfn//\à/a}
# newfn=${newfn//\é/e}
# newfn=${newfn//\è/e}
# newfn=${newfn//\í/i}
# newfn=${newfn//\ó/o}
# newfn=${newfn//\ö/o}
# newfn=${newfn//\ő/o}
# newfn=${newfn//\ú/u}
# newfn=${newfn//\ü/u}
# newfn=${newfn//\ű/u}
# newfn=${newfn//\Á/A}
# newfn=${newfn//\É/E}
# newfn=${newfn//\È/E}
# newfn=${newfn//\Í/I}
# newfn=${newfn//\Ó/O}
# newfn=${newfn//\Ö/O}
# newfn=${newfn//\Ő/O}
# newfn=${newfn//\Ú/U}
# newfn=${newfn//\Ü/U}
# newfn=${newfn//\Ű/U}
newi="$pathname/$newfn"
if [ "$i" != "$newi" ]
then
if [ -f "$newi" ]
then
echo "$newi exists, skipping $i"
else
echo "$i --> $newi"
mv "$i" "$newi"
fi
fi
fi
done