代码: 全选
#!/bin/bash
current_path[0]="./"
process_cn2hk(){
filename_original="$1"
filename_hk=`echo "$filename_original" | cconv -f utf-8 -t utf8-hk`
if [ "$filename_original" == "$filename_hk" ]; then
echo ------------------------------------
for var in ${current_path[@]};do
echo -n "$var"
done
echo "$filename_original"
else
echo "++++++++++++++++++++++++++++++++++++"
#
echo -n "<-"
for var in ${current_path[@]};do
echo -n "$var"
done
echo "$filename_original"
#
echo -n "->"
for var in ${current_path[@]};do
echo -n "$var"
done
echo "$filename_hk"
#
mv "$filename_original" "$filename_hk"
fi
}
duke_ergod()
{
for x in *
do
process_cn2hk "$x"
done
#
for x in *
do
if [ -d "$x" ];then
cd "$x";
current_path[${#current_path[@]}]="$x/"
duke_ergod;
cd ..
unset current_path[${#current_path[@]}-1]
fi
done
}
if [ "$1" == "-all" ]; then
duke_ergod
elif [ "$1" == "-nonce" ]; then
for files in *
do
process_cn2hk "$files"
done
else
echo "change all: cn2hk -all"
echo "change nonce: cn2hk -nonce"
fi