PHP script for reducing WGET downloaded Chinese catalog

zhaozj2021-02-08  247

For Linux version:

#! / usr / local / bin / php

# Author: hutuworm # Date: 20031115

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

// 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 ";

?>

转载请注明原文地址:https://www.9cbs.com/read-3145.html

New Post(0)