- !/usr/bin/php -q
$dir = '.';
$dh = opendir ($dir)
or die ("Fehler beim Oeffnen von $dir...n");
while (($file = readdir($dh)) !== false) {
if (preg_match ('/.txt$/i', $file)) {
$infile = fopen ($file, "r");
$outfilename = "$file.utf-8";
$outfile = fopen ($outfilename, "w");
if ($infile and $outfile) {
while (!feof ($infile)) {
$line = fgets ($infile, 1024);
fputs ($outfile, iconv ("ISO-8859-1", "UTF-8", $line));
}
fclose ($outfile);
fclose ($infile);
}
}
}
closedir ($dh);
?>