Page 1 of 1

rename with glob

Posted: Thu Sep 09, 2010 10:23 am
by peterhall
the code:

Code: Select all

<?php
    

foreach(glob("D:/dir/dir/*.csv") as $n => $file) {
    $new = dirname($file) . '/' . sprintf("%04d", $n + 1) . 'D:/dir/dir/test/*.csv';
    rename($file, $new);
 }

?>
the error:
Warning: rename(D:/dir/dir/file1.csv,D:/dir/dir/0001D:/dir/dir/test/file1.csv) [function.rename]: No error in C:\wamp\www\move.php on line 6

Warning: rename(D:/dir/dir/file2.csv,D:/dir/dir/0002D:/dir/dir/test/file2.csv) [function.rename]: No error in C:\wamp\www\move.php on line 6
what could it be????

Re: rename with glob

Posted: Thu Sep 09, 2010 10:42 am
by mikosiko
the error is not clear?

Code: Select all

rename(D:/dir/dir/file1.csv,D:/dir/dir/0001D:/dir/dir/test/file1.csv)
this "D:/dir/dir/0001D:/dir/dir/test/file1.csv" (the $new name) don't look like a valid file name isn't?