Skip to content

Instantly share code, notes, and snippets.

@andreykin
Created August 30, 2021 16:57
Show Gist options
  • Save andreykin/3feb0f41d9b53b6170b63fbdb37910f9 to your computer and use it in GitHub Desktop.
Save andreykin/3feb0f41d9b53b6170b63fbdb37910f9 to your computer and use it in GitHub Desktop.
convert_utf8.sh
# convert windows-1251 files to utf-8 in folder recursive.
# creates "_backup" folder with original files
# check if file is already encoded
for f in $(find . -name "*.css");
do
if file --mime-encoding $f | grep -wqe "iso-8859-1" -e "unknown-8bit"
then
mkdir -p _backup/$(dirname ${f})
cp $f ./_backup/$(dirname ${f})
iconv -f cp1251 -t utf8 $f > "${filename}_utf8.tmp"
mv "${filename}_utf8.tmp" $f
echo $f": CONVERTED TO UTF-8."
else
echo $f": UTF-8 ALREADY."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment