XML generator for XML gallery

Hi !
Just thought I would share some usefull code for those people out there that require huge amounts of xml for their gallery.

I recently came accross a client that had hundreds of images to display online in various categories, so I threw together this little xml generating script so I wouldnt have to manually type all of those in.

The key here is that I used adobe bridge Batch Rename feature to name images in a sequentil manner (i01.jpg, i02.jpg, i03.jpg … and so on). Then I would put each category of images in a folder called /images/+categoryname on the ftp.

var category:String = "photography";
var numimg:Number = 50;
var imgprefix:String = "p";



trace("<"+category+">");
for (var i = 1; i<=11; i++) {
    var j:String = String(i);
    //in this example all my files have 2 digits
    //This will ad a 0 in the files lower that 10
    var z:String;
    if (i<10) {
        z = "0";
    } else {
        z = "";
    }
    trace("  <image>");
    trace("    <title></title>");
    trace("    <hires>/images/"+category+"/"+imgprefix+z+j+".jpg</hires>");
    trace("    <thumb>/images/"+category+"/thumbnails/"+imgprefix+z+j+".jpg</thumb>");
    trace("  </image>");
}
trace("</"+category+">");

After that I simply copied the output into an xml document for each category.

And this is how I turned 15 hours of work into barely 30 minutes of work :slight_smile:

(oh and if you make this for a client, make sure he doesnt mind you changing his filenames !!! in this case they were all called DS000344.jpg (fresh out of the digital camera kind of file name) so he didnt mind