1.先安装recode和uchardet命令
sudo apt-get -y install recode uchardet > /dev/null
#!/bin/bash
find "$1" -type f | while read FFN # 'dir' should be changed...
do
encoding=$(uchardet "$FFN")
echo "$FFN: $encoding"
enc=`echo $encoding | sed 's#^x-mac-#mac#'`
set +x
recode $enc..UTF-8 "$FFN"
done
3.运行命令
chmod +x convert.sh
./convert.sh dir_you_want_to_UTF-8