Created
March 25, 2015 01:22
-
-
Save j1cs/add68b8e9dd3c6ef3459 to your computer and use it in GitHub Desktop.
convertir todos los archivos de un directorio a UTF8
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/bash | |
# converting all files in a dir to utf8 | |
for f in * | |
do | |
if test -f $f | |
then | |
echo -e "\nConverting $f" | |
CHARSET="$( file -bi "$f"|awk -F "=" '{print $2}')" | |
if [ "$CHARSET" != utf-8 ]; then | |
iconv -f "$CHARSET" -t utf8 "$f" -o "$f" | |
fi | |
else | |
echo -e "\nSkipping $f - it's a regular file"; | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment