#!/bin/bash if [ ! -d ${1} ]; then echo "recode: invalid or missing directory \`${1}'; exit."; exit 1; fi if iconv /dev/null; then : else echo "recode: unable to invoke iconv(1) converter utility."; fi if [ -z "${LOGONTMP}" ]; then LOGONTMP=${HOME} fi DATE=`date "+%Y-%m-%d"` LOG=${LOGONTMP}/recode.${DATE}.log files=$(find ${1} -type f -print) { for file in ${files}; do if [ "${file}" != "${file%%.gz}" ]; then echo "skipping \`${file}' (compressed)"; continue; fi if [ "${file}" != "${file%%-}" ]; then echo "skipping \`${file}' (back-up)"; continue; fi if iconv -f ISO-8859-1 -t ISO-8859-1 < ${file} > /dev/null 2>&1; then echo -n "recoding \`${file}' ... "; mv ${file} ${file}-; iconv -f ISO-8859-1 -t UTF-8 ${file}- > ${file} echo "done"; else echo "skipping \`${file}' (UTF-8)"; fi done } 2>&1 | tee -a ${LOG}