Exporting Visible layers in photoshop using script.
Hi,
I am new to adobe scripting, so please forgive me if this has been covered before.
I have a script from Chandler McWilliam's Adobe Scripting book, which I would like to use. Essentially it exports all the visible layers in an open PS document. The script works, but I cannot get it to export to a folder/location of my choosing. It defaults to exporting to the folder which contains the Photoshop application.
I am using a Mac.
The Script looks like this:
function exportVisible(doc) {
var myJPEG = new JPEGSaveOptions();
myJPEG.quality = 10;
myJPEG.formatOptions = FormatOptions.STANDARDBASELINE;
var myPath = "/Users/si/Desktop/JAVATESTFOLDER";
var myFolder = new Folder(myPath);
myFolder.create();
var settings = new Array();
var current; // current layer reference
for (var i=0; i<doc.layers.length; i++) {
current = doc.layers;
settings = current.visible;
doc.layers.visible = false;
}
for (var i=0; i<doc.layers.length; i++) {
current = doc.layers;
if (settings) {
current.visible = true;
var myFile = new File("Img-" + current.name + ".jpg");
doc.saveAs(myFile, myJPEG, true);
current.visible = false;
}
}
for (var i=0; i<doc.layers.length; i++) {
current = doc.layers;
current.visible = settings;
}
}
exportVisible(activeDocument);
I have tried numerous variations, but to no avail. I would be very grateful for any advice.
