Forum Moderators: bakedjake
iconv command to automatically generate UTF-8 versions of each file. However, I want to automate this rather than doing it file by file, but my pitiful bash skills are not up to getting this working. Here's my first attempt:
#/bin/bash
for i in *.php;
do iconv -f iso-8859-1 -t utf-8 %i -o %i_utf-8;
do mv %i_utf-8 %i;
done But I get the error:
iconv: cannot open input file `%i': No such file or directory Could anyone tell me where I'm going wrong? I've also got Python 2.4.1 or Perl 5.8 or PHP 4.3.10 if bash isn't the most appropriate tool.
Many thanks for any insight!
I'm getting a different error now, but I think there's signs of progress:
/home/example/bin/convert.sh: line 6: `$i': not a valid identifier My script now reads like this:
#/bin/bash
LIST=`ls *.php`
for $i in $LIST ;
do iconv -f iso-8859-1 -t utf-8 %i -o %i_utf-8;
mv %i_utf-8 %i;
done Am I using
%i incorrectly or do I need to define it differently?