I am creating a small personal tool that removes/moves files to the trashcan.
For doing this, I use the FolderItem.delete methode and it works, except the “Put Back” option is not available.
When I try to use an Applescript using Finder to delete the files it does work as expected.
But I want to avoid Applescript (for various reasons).
My questions:
How can I send a file to the trashcan that enable “Put Back”? Why does the FolderItem.Delete not enable this by default? Is the Xojo Framework using non-macos-compiant ways to remove files?
Maybe with a macOS API declare? Maybe the MBS plugins can help here?
In the “good old” Mac OS days, the “put back” location was actually stored with a file, in the directory.
Nowadays, however, Only Apple’s Finder knows about the Put Back location. Or maybe it’s stored in some secret file, like .DS_Store. Certainly nothing that we can easily access, AFAIK.
So, AppleScript (or AppleEvents, which is effectively the same) may be your only solution, as only that lets the Finder perform the operation (along with making sure the file is renamed in the Trash if necessary, and asking the user for permissions if needed).
Oh, wait. See this: https://stackoverflow.com/a/27847797/ - I believe MBS has this function available. Give it a try (you can try MBS plugins without payment as long as you only run it in the debugger).