Quote:
Originally Posted by isarl
Code:
for file in $(find . -type f) ; do
if [[ $(chardetect "$file" --minimal) == "Windows-1252" ]] ; then
iconv -f cp1252 -t utf-8 "$f" -o "$f.utf8"
mv "$f.utf8" "$f"
fi
done
|
The more I look at this, the more I worry that it might break if your filenames have a space character in them or something. It might be better to use find's -execdir option instead. Maybe something like:
Code:
read -r -d '' bash_script <<'EOF'
if [[ $(chardetect "{}" --minimal) == "Windows-1252" ]] ; then
iconv -f cp1252 -t utf-8 "{}" -o "{}.utf8"
mv "{}.utf8" "{}"
fi
EOF
find . -type f -execdir bash -c "$bash_script" ';'