Last active
March 20, 2016 18:57
-
-
Save sistematico/6047b4a7f454291e19eb to your computer and use it in GitHub Desktop.
Conversão de arquivos para UTF-8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cod1="utf-8" | |
for arquivo in $*; do | |
if [ "$(file --mime-type ${arquivo} | cut -d ' ' -f2)" == "text/plain" ]; then | |
cod2=$(file --mime-encoding ${arquivo} | cut -d ' ' -f2) | |
if [ "$cod2" != "$cod1" ]; then | |
echo "Convertendo o $arquivo de $cod2 para ${cod1}..." | |
iconv -f $cod2 -t $cod1 "$arquivo" -o "${arquivo}.tmp" | |
mv $arquivo $arquivo.old | |
mv $arquivo.tmp $arquivo | |
else | |
echo $arquivo já está em $cod1 | |
fi | |
else | |
echo "Tipo de arquivo inválido." | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment