$dir = 'files/';
$dh = opendir($dir);
while (($fn = readdir($dh)) !== false){
$file = $dir.$fn;
if (is_file($file)){
$cont = file_get_contents($file);
$cont = mb_convert_encoding($cont, 'UTF-8', 'WINDOWS-1251');
file_put_contents($file, $cont);
}
}