How can I align layers side-by-side and crop them automatically in Photoshop CS5?
I would use the same technique I detailed here.
Essentially, surround each layer with a guide, then use the slice tool (specifically the Slices From Guides button from the toolbar), then you can use File → Save For Web & Devices... to "automatically" crop each layer.
You can try writing your own or looking for existing scripts for Photoshop (.jsx file) to crop images
I would try to find a script that cuts an image then saves just the cut one... you can use save for we to do that.