Converting files from ISO-8859-1 to UTF-8
With a simple command you can convert a file from ISO-8859-1 encoding to UTF-8 encoding.
iconv -f iso-8859-1 -t utf-8 file1 > file2#!/bin/bash
if [ $# -ne 1 ]
then
echo "Script requires one argument, the folder to be converted from iso to utf."
exit
fi
mkdir utf8.$1
cd utf8.$1
(cd ../$1; find -type d ! -name .) | xargs mkdir
cd ..
for i in `find $1 -type f -print`;
do
#converts text files
if [[ $i == *.php ]] || [[ $i == *.js ]] || [[ $i == *.css ]] || [[ $i == *.html ]] || [[ $i == *.txt ]]
then
echo "[CONVERT]: $i";
iconv -f ISO-8859-1 -t UTF-8 $i -o utf8.$i;
else
echo "[COPY]: $i";
cp $i utf8.$i
fi
doneExample
Last updated
Was this helpful?