I have a directory which contains both ISO-8859 and UTF8 encoded files. I want to convert all ISO files to UTF8 encoding, and leave the UTF8 files untouched. So far, I've got this:
for isoFile in `file exports/invoice/* | grep "ISO-8859"`; do iconv -f iso-8859-1 -t utf-8 "$isoFile" -o "$isoFile"; done
The problem is that file exports/invoice/* | grep "ISO-8859" returns a list of files in this format:
exports/invoice/2014.03547.html: HTML document, ISO-8859 text, with very long lines, with CRLF, LF line terminators
which of course will not work for iconv. I need to extract the filename from this string and run it through iconv.