This article mainly introduces the PHP implementation of batch rename all files under a folder method, involving PHP for files under the folder traversal, string lookup, interception and rename function rename files and other related operations skills, the need for friends can refer to the following
The example in this article describes how PHP implements batch renaming of all files under a folder. Share to everyone for your reference, as follows:
Oneself manually Such a rename, tired Ah. So let's just take a lazy look.
The rule I renamed is to replace all spaces with a "_" and then add a "_s" to the back.
<?php$paths = "c://documents and settings//sk//desktop//s//"; $d = Dir ($paths), while (false!== ($entry = $d->read () ) { $table _change = Array (' ' = ' _ '); $newName = Strtr ($entry, $table _change); $newName = substr ($newName, 0,-4); Rename ($paths. $entry, $paths. $newName. " _s.jpg ");} $d->close (); echo "Done";? >