Skip to content

Instantly share code, notes, and snippets.

@j1cs
Created March 25, 2015 01:22
Show Gist options
  • Save j1cs/add68b8e9dd3c6ef3459 to your computer and use it in GitHub Desktop.
Save j1cs/add68b8e9dd3c6ef3459 to your computer and use it in GitHub Desktop.
convertir todos los archivos de un directorio a UTF8
#!/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