View Full Version : rename files
11-07-2012, 04: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 ?
11-07-2012, 04: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.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.