这下面的脚本几乎做我需要的。我想要做的是浏览已打开的文档,其中139个,并将它们保存为jpeg。但是它缺少的是从一个打开的文档移动到另一个,所以它保存了139次相同的图像。我假设doc.close()
会关闭打开的文档并给出新的焦点,但事实并非如此。photoshop JavaScript脚本问题
下面的代码:
var destination = "C:/Documents and Settings/Administrator/My Documents/small images"
for(var i = 0; i < 5; i++)
{
doc = documents[i];
name_ = doc.name.substring(0, doc.name.indexOf('.'))
saveForWebPNG(destination, name_);
doc.close();
}
function saveForWebPNG(outputFolderStr, filename)
{
var opts, file;
opts = new ExportOptionsSaveForWeb();
opts.format = SaveDocumentType.JPEG;
opts.quality = 60;
if (filename.length > 27) {
file = new File(outputFolderStr + "/temp.jpg");
activeDocument.exportDocument(file, ExportType.SAVEFORWEB, opts);
file.rename(filename + ".jpg");
}
else {
file = new File(outputFolderStr + "/" + filename + ".jpg");
activeDocument.exportDocument(file, ExportType.SAVEFORWEB, opts);
}
}
链接给了404。 – expiredninja 2015-01-12 07:11:56