European Open Root Server Network

Convert Charset recursively

You have to convert a whole bunch of files recursively from one charset to another? Want to keep the timestamps all the same? Here's what we do:

for FILE in $(find . -type f -name '*.php' | grep -v ./blog/wordpress); do iconv -f ISO-8859-15 -t UTF-8 "$FILE" > "$FILE.new"; touch -r "$FILE" "$FILE.new"; mv "$FILE.new" "$FILE"; done