Image



I'm trying to learn how to script for Photoshop CS2, but it's tough and I'm not finding much help. Basically, all I want to do is resave and close a bunch of psd images as jpeg but only if they don't have more than one layer. Then I would like it to remove the old psd file. Someone helped me with some code, but it doesn't seem to work and because I'm JScript retarded, I cannot figure it out on my own.

var doc = app.activeDocument;
if (doc.layers.length == 1) {
var opts = JPEGSaveOptions();
opts.quality = 10; // set your jpeg options here
var file= doc.fullName;
var jpegfile = new File(file.replace(/\.psd$/, ".jpg");
doc.saveAs(jpegfile, opts, true);
doc.close(SaveOptions.DONOTSAVECHANGES);
}

I've downloaded and bought a couple of JScript books now, so hopefully soon I'll be able to help myself and others, but any help on this question in the meantime would be FANTASTIC!

ps - I asked at http://www.ps-scripts.com/bb/ but couldn't really get much of an answer