【发布时间】:2017-12-30 03:35:21
【问题描述】:
所以我一直在寻找这个问题的答案,但没有运气。是否可以在 Mac 自动化中使用 JXA 将文件发送到垃圾箱?我的简单测试代码如下所示:
// set startup applications that this script will use
var app = Application.currentApplication()
var finder = Application("Finder");
app.includeStandardAdditions = true
function openDocuments(droppedItems)
{
// Variables
var AllFiles = [] // array to store all files in.
for (var item of droppedItems)
{
AllFiles.push(item) // load each file into array
}
// go through each file in the list
for (var i = 0; i < AllFiles.length; i ++)
{
// move to the trash
finder.move(Path(AllFiles[i]), {
to: Path("/Users/usr/.trash"),
replacing: true
})
}
}
这只是我正在构建的一个测试,它应该将我放到它上面的任何文件发送到垃圾箱,但它不会将 .trash 识别为有效的文件夹位置。我已经用其他文件夹对其进行了测试,并且确实有效,所以我假设 .trash 已被锁定。
【问题讨论】:
标签: javascript macos automation javascript-automation