-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgbtobig5
More file actions
executable file
·39 lines (38 loc) · 1002 Bytes
/
gbtobig5
File metadata and controls
executable file
·39 lines (38 loc) · 1002 Bytes
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
#!/bin/bash
r=0
function myhelp() {
echo Usage: gbtobig5 [-r] FILE
echo rename the gbcode filename to big5code filename
echo
echo -r, --recursive rename the contents of directories recursively
echo -h, --help show this help page
echo
echo
echo auther: kenshinn, taiwan
echo webpage: http://kenshinnn.blogspot.com
echo E-mail: kenshinnn@gmail.com
echo Msn: kenshinnkimo@msn.com
echo
echo updated on 2008/06/21
exit
}
function ren() {
i=$1
j=`echo $i|iconv -c -f utf8 -t gb2312 | iconv -c -f gb2312 -t big5 | iconv -c -f big5 -t utf8`
if [ $i = $j ] ; then return ; fi
echo `pwd`\/$i rename to `pwd`\/$j
mv $i $j
}
function dr() {
for i in $@ ; do
if [ -d $i ] && [ $r = 1 ] ; then cd $i ; dr * ; i=`basename \`pwd\`` ; cd .. ; fi
if [ -e $i ] ; then ren $i ; fi
done
}
IFS=""
if [ $# == 0 ] ; then myhelp ; return ; fi
for c in $@ ; do
if [ $c = -h ] || [ $c = --help ] ; then myhelp ; fi
if [ $c = -r ] || [ $c = --recursive ] ; then r=1 ; continue ; fi
done
dr $@