Skip to content

Instantly share code, notes, and snippets.

@lqinggang
Forked from GiaoGiaoCat/.sh
Created April 13, 2017 10:01
Show Gist options
  • Save lqinggang/6395c3ca4ef4cbdaf5982687f4d889ea to your computer and use it in GitHub Desktop.
Save lqinggang/6395c3ca4ef4cbdaf5982687f4d889ea to your computer and use it in GitHub Desktop.
批量转换文件编码
#!/bin/bash
DIR=$1 # 转换编码文件目录
FT=$2 # 需要转换的文件类型(扩展名)
SE=$3 # 原始编码
DE=$4 # 目标编码
for file in `find $DIR -type f -name *.$FT`; do
echo "conversion $file encoding $SE to $DE"
iconv -f $SE -t $DE "$file" > "$file".tmp
mv -f "$file".tmp "$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment