Javascript Export to Photoshop files not writing layers
Hello,
I've been trying to adapt an Illustrator script that can batch convert a folder of .ai files to .psd files with layers but the result is always flattened.
var folder = Folder.selectDialog();
if (folder) {
var files = folder.getFiles("*.ai");
for (var i = 0; i < files.length; i++) {
var currentFile = files[i];
app.open(currentFile);
var activeDocument = app.activeDocument;
var ExpFolder = Folder(currentFile.path);
var fileName = activeDocument.name.split('.')[0] + ".psd";
var destinationFile = File(ExpFolder + "/" + fileName);
var type = ExportType.PHOTOSHOP;
var options = new ExportOptionsPhotoshop();
options.writeLayers = true;
options.maximumEditability = true;
options.antiAliasing = true;
options.editableText = true;
//options.imageColorSpace = ImageColorSpace.Grayscale; << not working
options.resolution = 1200;
activeDocument.exportFile(destinationFile, type, options);
activeDocument.close(SaveOptions.DONOTSAVECHANGES);
currentFile = null;
}
}
Also setting the imageColorSpace to Grayscale results in an error.
Doing some trial and error, it seems the ExportOptionsPhotoshop object is not getting the arguments passed down to it beside the resolution.
Batch Illustrator Actions with File > Export > Export As... works but I'd like to control the destination folder and file names with additional variables.
Thanks a lot in advance for your kind help !
Fabien
