So I have been looking for an answer to this and have had no luck. Is it possible to send a file to the trash using JXA in Mac Automation? my simple test code looks like this:
// 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
})
}
}
this is just a test I am building that should send whatever file I drop onto it to the trash, but it does not recognize .trash as a valid folder location. I have tested it with other folder and that does work so I am assuming that .trash is locked.