Photoshop Javascript脚本保存和关闭文档

Bar*_*ney 2 javascript photoshop scripting

我出于某种原因无法保存; 我正在使用Photoshop CS5.1(如果这确实是问题的原因)

error 8800: General Photoshop error occurred. 
This functionality may not be available in this version of Photoshop.
Could not save a copy as C:\...\Temp001.jpeg0011338281522" 
because the file could not be found
Run Code Online (Sandbox Code Playgroud)


var thistimestamp = Math.round(new Date().getTime() / 1000);
saveFile = new File( "/Users/Barny/My Pictures/Temp001" +thistimestamp+ ".jpeg" )
saveOptions = new JPEGSaveOptions();
saveOptions.embedColorProfile = true;
saveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
saveOptions.matte = MatteType.NONE;
saveOptions.quality = 9;
app.activeDocument.saveAs(saveFile, saveOptions, true,Extension.LOWERCASE);
Run Code Online (Sandbox Code Playgroud)

我想要保存和关闭脚本,但我一直收到这个错误.我正在使用Photoshop CS5.1(如果这确实是问题的原因)

pdi*_*izz 6

General Photoshop error保存时出现错误通常意味着保存路径出现问题.Photoshop正在尝试保存到不存在的位置.这假设文件夹C:/Users/Barney/Pictures/Temp001存在:

var thistimestamp = Math.round(new Date().getTime() / 1000);
saveFile = new File( "c:/Users/Barney/Pictures/Temp001/" +thistimestamp)
saveOptions = new JPEGSaveOptions();
saveOptions.embedColorProfile = true;
saveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
saveOptions.matte = MatteType.NONE;
saveOptions.quality = 9;

app.activeDocument.saveAs(saveFile, saveOptions, true,Extension.LOWERCASE);
Run Code Online (Sandbox Code Playgroud)

我做的唯一更改是路径字符串saveFile = new File("C:/Users/Barney/Pictures/Temp001/" + thistimestamp)通知我添加了C:使其成为绝对路径并/在Temp001之后添加了一个指定这是一个文件夹而不是最终文件名的一部分.My Pictures应该是Pictures(我的图片只是一个别名),如果你从地址栏复制地址,这是你得到的.我也删除了+ ".jpeg"因为photoshop负责处理文件扩展名.

如果您要创建新文件夹,则必须使用该Folder对象:

var myfolder = new Folder("c:/Users/Barney/Pictures/Temp001/");
myfolder.create();
Run Code Online (Sandbox Code Playgroud)