【发布时间】:2021-11-28 10:44:53
【问题描述】:
我有一个用于 indesign 脚本的 jsx 脚本。下面的函数用于写入文件。它在 Windows 中完美运行。在 mac 中,它无法从应用程序文件夹中创建不读取文件。是不是和mac的权限有关??
我确实尝试过使用 applescript 创建文件。代码工作正常,没有错误,但没有创建文件。与以下功能相同。该代码完美运行。但我无法在文件夹中创建 txt 文件。
fileobject = "应用程序/文件夹名/文件名.txt" 文件内容 = "文本"
function writeToFile(fileObj, fileContent){
encoding = encoding || "utf-8";
fileObj = (fileObj instanceof File) ? fileObj : new File(fileObj);
var parentFolder = fileObj.parent;
if (!parentFolder.exists && !parentFolder.create())
throw new Error("Cannot create file in path " + fileObj.fsName);
fileObj.encoding = encoding;
fileObj.open("w");
fileObj.write(fileContent);
fileObj.close();
return fileObj;
}
【问题讨论】:
-
它在 10.15 上对我有用,所以你应该没有问题。这将写入顶部的应用程序文件夹。您确定您没有检查 /Users/YourName/Applications 中的本地用户 Applications 文件夹,而不是 /Applications 中的顶级 Applications 文件夹吗?
标签: macos scripting jsx adobe-indesign extendscript