Batch convert files to utf-8
I recently had to convert a directory structure of files from Windows created ISO-8859-1 format to standard Unicode UTF-8.
I created a shell script that recursively creates a copy of the directory tree converting to Unicode each PHP file it finds.
find . -name "*.php" -exec iconv -f ISO-8859-1 -t UTF-8 {} -o ../newdir_utf8/{} \;
It was originaly made to be run inside the directory I wanted to convert, but it can be easily changed in order to run from anywhere.
Hope it’s useful to someone having this problem.

# find . -name "test.html" -exec iconv -f CP1251 -t UTF-8 {} -o utf-8/{} \;didn’t work…. =-/Hi, thanks for this post. It saved me hours of manual converting file for file. This solution were a little bit more complicated:
http://ubuntuforums.org/showthread.php?t=9369
And this solution just worked for one file:
http://mediakey.dk/~cc/howto-convert-text-file-from-utf-8-to-iso-8859-1-encoding/
#!/bin/sh
count=0;
for proc in `find /work/webserver/pfgrussia/data/bitrix/modules/compression/lang/ru/ -name “*.php”`; do iconv -f CP1251 -t UTF-8 $proc > ${proc//.php/.utf};
echo “$count: ${proc//.php/.utf}”; ((count++)); done;
for proc in `find /work/webserver/pfgrussia/data/bitrix/modules/compression/lang/ru/ -name “*.utf”`; do mv -f $proc ${proc//.utf/.php}; echo “$count: ${proc/
/.utf/.php}”; ((count++)); done;