For Linux version:
#! / usr / local / bin / php
# Author: hutuworm # Date: 20031115
phpFunction TravelDir ($ DIRNAME) {IF ($ DIRNAME [Strlen ($ DIRNAME) -1]! = '/') $ dirName. = '/'; $ dirhandle = Opendir ($ DIRNAME); while ($ file = ReadDir ($ DirHandle) {IF ($ file == '.' || $ file == '..') Continue; if (is_dir ($ DIRNAME. $ file) {$ newname = quoted_printable_decode (EREG_REPLACE " "," = ", $ dirname. $ file); $ realName = '" "$ newname.'" '; $ lyname =' "'" $ dirname. $ file.' "; if ($ oldname! = $ realName) System ("MV $ OLDNAME $ RealName); TravelDir ($ newname. '/');} else continue;} closedir ($ dirhandle);
IF ($ argv [1]) && is_dir ($ ARGV [1])) {$ targetdir = $ argv [1]; traveldir ($ targetdir);} else echo "usage: ./dirdecode.php / path / TO / DIR / N ";
?>
For Windows:
#! / usr / local / bin / php -a
# Author: hutuworm # Date: 20031115
PHP
// Traverse the catalog and restore the Chinese directory name Function TravelDir ($ DIRNAME) {IF ($ DIRNAME [Strlen ($ DIRNAME) -1]! = '//') $ DIRNAME. = '//'; $ DirHandle = OpenDir $ DIRNAME); WHILE ($ file = readdir) {if ($ file == '.' || $ file == '..') Continue; if (is_dir ($ dirname. $ file) { $ newname = quoted_printable_decode (EREG_REPLACE ("%", "=", $ file); $ oldname = '"" $ dirname. $ file.' "; if ($ file! = $ newname) {$ realname = '"$ newname.'"; system ("Ren $ OLDNAME $ RealName);} TravelDir ($ DIRNAME. $ NEWNAME. '//');} else continue;} closedir ($ dirhandle);} if (isset ($ Argv [1]) && is_dir ($ ARGV [1])) {$ targetdir = $ argv [1]; TravelDir ($ Targetdir);} else echo "Usage: C: / PHP / PHP DIRDECODE.PHP / path // TO / DIR / N ";
?>