iconv.sh 315 Bytes
Newer Older
Mart Lubbers's avatar
Mart Lubbers committed
1 2 3 4 5 6 7 8 9 10
#!/bin/bash
shopt -s globstar
for f in /opt/clean/lib/**/*.[id]cl; do
	enc="$(file -bi "$f" | grep -Po '(?<=charset=).*')"
	if [ "$enc" != 'us-ascii' -a "$enc" != 'binary' -a "$enc" != 'utf-8' ]; then
		iconv -f "$enc" -t utf-8 < "$f" > "$f.tmp"
		mv "$f.tmp" "$f"
		echo "converted $f from $enc to utf-8"
	fi
done