Home > Article > Backend Development > PHP method to rename all files in a folder
This article mainly introduces the method of renaming all files under a folder in PHP, involving PHP's related operation skills such as traversing, string search, interception and renaming files under the folder, etc., which requires Friends can refer to the following details:
<?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"; ?>
Detailed explanation of node.js file upload, renaming and moving position
The above is the detailed content of PHP method to rename all files in a folder. For more information, please follow other related articles on the PHP Chinese website!