Javascript 自动保存在Windows上有效,但在Mac上无效

Javascript 自动保存在Windows上有效,但在Mac上无效,javascript,photoshop,photoshop-script,Javascript,Photoshop,Photoshop Script,我遵循此线程()中提供的代码,在没有“另存为…”对话框的情况下将图像覆盖/另存为PNG。它在我的Windows PC上运行良好。但我将脚本文件传递给了我的合作伙伴,他使用Mac,它无法运行。这就是他告诉我的错误: 以下是脚本: // The saved directory location of the main master document. Path = doc.path; // If the document is new there is no doc.path.

我遵循此线程()中提供的代码,在没有“另存为…”对话框的情况下将图像覆盖/另存为PNG。它在我的Windows PC上运行良好。但我将脚本文件传递给了我的合作伙伴,他使用Mac,它无法运行。这就是他告诉我的错误:

以下是脚本:

    // The saved directory location of the main master document.
    Path = doc.path;  // If the document is new there is no doc.path. Error is shown.

    // Save the file.
    var opts = new ExportOptionsSaveForWeb();
    opts.PNG8 = false;
    opts.transparency = true;
    opts.interlaced = false;
    opts.quality = 100;
    opts.includeProfile = false;
    opts.format = SaveDocumentType.PNG;
    activeDocument.exportDocument(Path, ExportType.SAVEFORWEB, opts);
    doc.close(SaveOptions.DONOTSAVECHANGES);

使用Photoshop,通常很难说为什么黑客软件在一个操作系统上工作,而在另一个操作系统上却不工作,我建议只给
.exportDocument()
提供一个完整的路径名:


我在我的Windows PC上试用过,以确保它在发送给我的合作伙伴之前工作正常。出于某种奇怪的原因,它保存了数据,但没有扩展名“.png”(但数据就在那里)。我右键单击保存的文件>进入属性>在其文件名后面添加了“.png”>点击应用,它将更改为一个正确的png文件。不确定为什么会发生这种情况,因为您的代码已经有了“.png”。我的将活动文档扩展名替换为png。我想如果你的活动文档没有扩展名来替换它,它不会添加png。。。可能会执行
doc.name.replace(/\..[^.]+$/g,“”+“.png”
?啊,是的,我忘了提到它没有扩展名,因为它是主控文档的临时复制文档。所以我有主文档保存位置的路径。不管怎样,这些代码在我的Windows上运行!现在我将等待我的搭档回复我:)
activeDocument.exportDocument(new File(Path + "/" + doc.name.replace(/\.[^.]+$/g, ".png")), ExportType.SAVEFORWEB, opts);