Search code examples
macosshellencodingglobiconv

osx change file encoding (iconv) recursive


I know I can convert a single file encoding under OSX using:

iconv -f ISO-8859-1 -t UTF-8 myfilename.xxx > myfilename-utf8.xxx

I have to convert a bunch of files with a specific extension, so I want to convert file encoding from ISO-8859-1 to UTF-8 for all *.ext files in folder /mydisk/myfolder

perhaps someobe know the syntax how to do this

thanks

ekke


Solution

  • Adam' comment showed me the way how to resolve it, but this was the only syntax I made it work:

    find /mydisk/myfolder -name \*.xxx -type f | \
        (while read file; do
            iconv -f ISO-8859-1 -t UTF-8 "$file" > "${file%.xxx}-utf8.xxx";
        done);
    

    -i ... -o ... doesnt work, but >

    thx again

    ekke