Do the following: for i in `ls -R Swedish-*`; do iconv -f ISO-8859-1 -t UTF8 $i -o UTF8-$i; done followed by: mkdir utf8 cp UTF-8* utf8 And then cd utf8 for file in UTF8-*; do mv "$file" "${file:5}"; done And finally for i in *; do sed -i '1s/^/$self{charset} = \x27UTF-8\x27; \n/' $i; done