2012-05-29 42 views
2

由于某种原因,我无法保存; 我使用的Photoshop CS5.1(如果这真的是问题的原因)Photoshop Javascript脚本保存和关闭文档

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 


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); 

我想脚本保存并关闭,但我不断收到这个错误。我使用的是Photoshop CS5.1(如果确实是问题的原因)

+1

在什么情况下是你的JS运行? –

回答

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); 

我所做的唯一变化是对路径字符串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();