note 90535 modified in function.rename by danbrown
| From: | danbrown@php.net | Date: | Mon, 27 Apr 2009 14:25:56 +0000 |
| Subject: | note 90535 modified in function.rename by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153814@lists.php.net to get a copy of this message | ||
Rename all the files at one. :)
<?php
$path = "E:\\SERVER\\sudhir\\songs";
$dh = opendir($path);
$i=1;
while (($file = readdir($dh)) !== false) {
if($file != "." && $file != "..") {
echo "<br/>".substr($path."\\".$file,
0,-3)."_mysongs_mp3";
rename($path."\\".$file, substr($path."\\".$file,
0,-3)."_mysongs_mp3");
$i++;
}
}
closedir($dh);
?>
--was--
Rename all the files at one. :)
$path = "E:\\SERVER\\sudhir\\songs";
$dh = opendir($path);
$i=1;
while (($file = readdir($dh)) !== false) {
if($file != "." && $file != "..") {
echo "<br/>".substr($path."\\".$file,
0,-3)."_mysongs_mp3";
rename($path."\\".$file, substr($path."\\".$file,
0,-3)."_mysongs_mp3");
$i++;
}
}
closedir($dh);
http://php.net/manual/en/function.rename.php