Answer the question
In order to leave comments, you need to log in
Bulk Rename ANSI Files >> UNICODE?
It so happened that when backing up CPanel, pictures that had names in Unicode (not Russian) became cracked (it looks like Chinese, but ANSI), so here's how to perform the reverse operation)
through php, windows app. or something else,
a lot of cardboard
Answer the question
In order to leave comments, you need to log in
In PHP
define('IN_CONV','CP1251');
define('OUT_CONV','UTF-8');
$dir='/some/dir/'
ansiutf($dir);
function ansiutf($dir)
{
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if($file!=='.' && $file!=='..' && is_dir($file)===false && is_image($file)===true)
rename($dir.$file,$dir.iconv(IN_CONV,OUT_CONV,$file));
elseif(is_dir($file)===true)
ansiutf($dir.$file.'/');
}
closedir($dh);
}
}
is_image($file)
{
$ext=substr($file,strrpos($file,'.'));
if($ext==='.gif' || $ext==='.png' || $ext==='.jpg' || $ext==='.jpeg')
return true;
else
return false;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question