Batch convert latin-1 files to utf-8 using iconv

Posted by Jasmo on Stack Overflow See other posts from Stack Overflow or by Jasmo
Published on 2010-12-28T08:24:34Z Indexed on 2010/12/28 8:53 UTC
Read the original article Hit count: 248

I'm having this one PHP project on my OSX which is in latin1 -encoding. Now I need to convert files to UTF8. I'm not much a shell coder and I tried something I found from internet:

mkdir new
for a in ls -R *; do iconv -f iso-8859-1 -t utf-8 <"$a" >new/"$a" ; done

But that does not create the directory structure and it gives me heck load of errors when run. Can anyone come up with neat solution?

© Stack Overflow or respective owner

Related posts about shell

Related posts about character-encoding