Added on: Wednesday 4th February 2009
The gallery uses a MySQL database and has a facility to index new photos that have been downloaded into a new folder.
Once the images have been indexed by the database they are moved from the download folder and renamed to match the reference in the database.
I made a stupid mistake when using this and managed to rename all the existing photos so that they no longer matched the database reference.
Not a major problem you might think as it is easy to write a quick php script to rename all the files in a folder.
However, the database also contains metadata about the photos and the new filenames no longer sorted into date taken order as they would have done when first indexed.
Luckily, php has a set of functions to extract the 'exif' data from a digital photo and using the read_exif_data function I was able to get the 'DateTimeOriginal' value for each photo.
It was easy enough to load these into an array, sort them and then loop through the array and rename the files.
So 10 minutes later I had my photo gallery back to the state it was in before I messed it up.
I've put the code in a text file for use by anyone who wants to do this.
Andrew Parrott runs Round Ash Associates, a web design and development company based in Chagford on Dartmoor, Devon.
If you prefer updates via email then please enter your email address below and click Submit.
If you haven't been to Chagford before then take a look a what you are missing.
Sitepoint is an indespensible resource for web designers.
Internet Explorer isn't the only web browser and from a development point of view Firefox is much better.
As many of the articles on this site are slightly techy I thought I ought to link to a glossary of Internet terms.
The layout for this site uses one of Matthew James Taylors 'liquid layouts'.
©Round Ash Associates 2009. Powered by form2list.