rename with glob

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
peterhall
Forum Newbie
Posts: 24
Joined: Sat Aug 21, 2010 5:47 pm

rename with glob

Post 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????
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: rename with glob

Post 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?
Post Reply