我尝试替换一个包含特殊字符的文件
从:
[v]_CØDE:BREAKER_-_01_[gg][D00B1].mkv
至:
[v]_CoDE:BREAKER_-_01_[gg][D00B1].mkv
但是当我尝试下面的代码时
if ($handle = opendir($refolder)) {
while (false !== ($entry = readdir($handle))) {
$renameTHEfile = $entry;
$renameTHEfile = str_ireplace("Ø","O",$renameTHEfile);
$renameTHEfile = str_ireplace('ø','o',$renameTHEfile);
$renameTHEfile = str_ireplace(":","_",$renameTHEfile);
$renameTHEfile = str_ireplace("!","",$renameTHEfile);
$renameTHEfile = str_ireplace("'","",$renameTHEfile);
$renameTHEfile = str_ireplace('"','',$renameTHEfile);
$renameTHEfile = str_ireplace(",","",$renameTHEfile);
$renameTHEfile = str_ireplace("#","",$renameTHEfile);
$renameTHEfile = str_ireplace("$","",$renameTHEfile);
$renameTHEfile = str_ireplace('/','',$renameTHEfile);
$renameTHEfile = str_ireplace("?","",$renameTHEfile);
$theoldfile_rename = $refolder . $entry;
$thenewfile_rename = $refolder . $renameTHEfile;
$cmd_renameit = 'move "' .$theoldfile_rename. '" "'.$thenewfile_rename .'"';
echo $cmd_renameit;
exec($cmd_renameit);
}
}
视频文件将输出为
[v]_CØDE
如何将其正确替换为,我还需要将 : 替换为 _
[v]_CODE_BREAKER_-_01_[gg][D00B1].mkv
感谢您的帮助。