Familien Schøler’s blog

Lidt af hvert fra hverdagen hos Michael, Kamilla, Marie og Katrine Schøler

Task scheduling for auto updating your JAlbum web albums

Hello JAlbum users,

I’m managing an ever growing collection of personal photos on a password protected section of my web page. To simplify and ensure the best experience for the photo album visitors, I’m of course using JAlbum. The problem is, JAlbum does not handle VERY large photo album structures all that well, mainly because its not directly intended for that. It is intended for quickly and painlessly publishing one or more photoalbums directly to a local www or FTP folder.

My families root photo album structure currently contains 25000+ images (approx. 75 Gb) dating back to 2000 (where I bought my first digital camera). And I’ve managed to set it all up so that JAlbum runs smoothly and fast for each new month that passes. Quite amazing!

The trick is of course to divide and conquer by placing photos in seperate folders, each using its own JAlbum project file. But that also means managing a steady growing collection of JAlbum project files. What to do?

I have all my raw photos grouped in subpaths on a USB harddrive as “H:\Data\Fotoalbum\YYYY\MM\…”, and I publish the albums to my web server running on a different harddrive (P:\Xampp\htdocs\YYYY\MM\fotoalbum\…). This gives a nice file structure and good permalinks to the online albums.

To continously update the albums, I’ve setup a simple scheduled task which triggers a bat file that generates the needed JAlbum project files and executes them automatically. Furthermore, the bat script generates an update bat script that is placed along side the generated JAlbum project files.

The bat script for the task scheduler looks like this:

@echo off
echo JAlbum processing h:\data\fotoalbum\%date:~6,4%\%date:~3,2%\ folder...
IF NOT EXIST h:\data\fotoalbum\%date:~6,4%\%date:~3,2% GOTO NODIR
  echo Album for specified month exists.
  echo Generating JAlbum project file based on template...
  h:
  cd h:\data\fotoalbum\
  echo #Task scheduler - Auto generated JAlbum project file> album.jap
  echo directory=H\:\\Data\\Fotoalbum\\%date:~6,4%\\%date:~3,2%\\>> album.jap
  echo outputDirectory=P\:\\xampp\\htdocs\\%date:~6,4%\\%date:~3,2%\\fotoalbum>> album.jap
  echo interpretedOutputDirectory=P\:\\xampp\\htdocs\\%date:~6,4%\\%date:~3,2%\\fotoalbum>> album.jap
  type jalbum-settings-template.jap >> album.jap
  copy album.jap h:\data\fotoalbum\%date:~6,4%\%date:~3,2%\jalbum-settings.jap
  del album.jap
  echo Generating photo album with the JAlbum command line tool...
  c:
  cd "c:\program files\jalbum\"
  java -jar JAlbum.jar -projectFile h:\data\fotoalbum\%date:~6,4%\%date:~3,2%\jalbum-settings.jap
  echo Copying website specific files to output www folder...
  copy h:\data\fotoalbum\index.html P:\xampp\htdocs\%date:~6,4%\%date:~3,2%\
  copy h:\data\fotoalbum\.htaccess P:\xampp\htdocs\%date:~6,4%\%date:~3,2%\fotoalbum
  echo Generating update script...
  echo c:> h:\data\fotoalbum\%date:~6,4%\%date:~3,2%\update.bat
  echo cd "c:\program files\jalbum\">> h:\data\fotoalbum\%date:~6,4%\%date:~3,2%\update.bat
  echo java -jar JAlbum.jar -projectFile h:\data\fotoalbum\%date:~6,4%\%date:~3,2%\jalbum-settings.jap>> h:\data\fotoalbum\%date:~6,4%\%date:~3,2%\update.bat
  goto ENDING
:NODIR
  echo Album for specified month was not found.
:ENDING
  echo Done.

[Download the script]

The most basic part of the bat script is “h:\data\fotoalbum\%date:~6,4%\%date:~3,2%\” which transforms into “h:\data\fotoalbum\2010\07\” for instance at any given day in July month of 2010. By using these “macros” the script is able to run time and time again, and always update the current months photo album folder. I’ve set the script to be run each day for now, ensuring that my albums are always up to date on the web page (provided I remember to actually take and upload new photos).

When the script runs it does several things:

1. Check that the current months album folder actually exists, if not, it stops and waits for the next scheduled run.

2. If the album exists it creates a file called “album.jap”

3. It fills in the following lines in the top of that file (based on the current year/month):

  #Task scheduler - Auto generated JAlbum project file> album.jap
  directory=H\:\\Data\\Fotoalbum\\2010\\07\\>> album.jap
  outputDirectory=P\:\\xampp\\htdocs\\2010\\07\\fotoalbum>> album.jap
  interpretedOutputDirectory=P\:\\xampp\\htdocs\\2010\\07\\fotoalbum>> album.jap

4. It then appends a template project file (jalbum-settings-template.jap), that I’ve already setup using the JAlbum UI. Basically setup any skin and various settings you want for your photo albums, and save it. Then just delete the three lines from above (“directory=…”, “outputDirectory=…” and “interpretedOutputDirectory=…”) and save that new project template file as “jalbum-settings-template.jap”.

5. The generated JAlbum project file is then copied into the photo album source folder (will be placed as “h:\data\fotoalbum\2010\07\jalbum-settings.jap” in this example), for later possible manual reinvocation / updates by you.

6. A number of website specific files are required on my site, and the bat script now copies these files into the output folder. For my site its a root index.html file that directs the “previous album” link from the index page of the album back to a search page I’ve made (that’s for a comming blog post). Also it places a .htaccess file that requires visitors to enter a login and password when browsing the album. This can be left out, or entirely customized for your sites needs.

7. Finally it runs the generated project file against the JAlbum command line tool, and finished off by saving an “update.bat” file in the source folder “h:\data\fotoalbum\2010\07″. When ever you want to manullay re-publish the album you simply activate this bat script, or you can go into the JAlbum UI and load the “jalbum-settings.jap” and publish from there.

Hope you find this useful.

Best regards
Michael

Send en kommentar