so I had this problem where I have to rename all files in a given folder to add timestamp at the start of the file name.
i.e. a.txt becomes 1324884311_a.txt
well your new files name pattern can be totally different, so this is just an indicator.
Also this is non recursive function and works on single folder only.
You may also be interested in looking at RecursiveDirectoryIterator class http://php.net/manual/en/class.recursivedirectoryiterator.php (requires PHP 5.3+)
Here is how I did it
First add this function to your Util class
function renameFiles($directory) { if ($file != "." && $file != "..") { } } // clean up }
Then I called this function on my directory like this
renameFiles("c:/myimages");
You can provide extra checks that can suit your need, or ask me If you have any specific need. the underlying logic to open a directory and reading all file names under it shall remain the same.
I am sort of not so active member on stackoverflow. But using the same technique I helped someone with similar problem
If you would like to have a look at my answer there you can browse to
http://stackoverflow.com/questions/9158355/renaming-alphanumeric-images-with-php/9158548#9158548
I hope above helps





JC WordPress Coupon Revealer Plugin Pro License
Australian Street Names with City, State and Display Names only, Single Server License
Recent Comments