If you are using Photoshop 7, you can use the Scripting plug-in and create a Java script that will do everything you want, including determining if the image is vertical or horizontal, and acting on the information. It can also put a watermark on the images, resize, etc. I have a few scripts I've written, and there are a few more out on the web. If this is an option for you, and I can be of any assistance, let me know.