...

View Full Version : rename files



paperino00
11-07-2012, 03:31 PM
Hello, I have 1000 files and i would like php to rename them if they have a certain name, how can I write somthink like foreach to check every file ?

thanks

Fou-Lu
11-07-2012, 03:39 PM
If there is a certain pattern to the names, you can iterate it using a glob or globIterator/RegexIterator or DirectoryIterator with a filter.
I'd suggest a glob; changing things during an iteration doesn't tend to be favourable, so dumping into an array with glob and traversing that with a foreach and renaming each item found in that array would be safe.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum