Skip to content

Instantly share code, notes, and snippets.

@pasha-pivo
Forked from akost/convert.sh
Last active April 26, 2018 07:25
Show Gist options
  • Save pasha-pivo/74873d0adbe8273abdd30f52b4ac3e17 to your computer and use it in GitHub Desktop.
Save pasha-pivo/74873d0adbe8273abdd30f52b4ac3e17 to your computer and use it in GitHub Desktop.
Bash script for recursive file convertion windows-1251 --> utf-8
#!/bin/bash
# Recursive file convertion windows-1251 --> utf-8
# To add file type by extension, e.g. *.cgi, add '-o -name "*.cgi"' to the find command
find ./ -name "*.txt" -o -name "*.html" -type f |
while read file
do
echo " $file"
mv "$file" "$file".icv
iconv -f WINDOWS-1251 -t UTF-8 "$file".icv > "$file"
rm -f "$file".icv
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment