1.先安装recode和uchardet命令
sudo apt-get -y install recode uchardet >/dev/null
2.创建脚本文件convert.sh如下:
#!/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