ekkescorner ekkescorner - 3 years ago 357
Bash Question

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



Answer Source

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";

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

thx again


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download