On 13/03/2013, at 10:06 PM, Brian Christmas <email@hidden> wrote:
Is there a command in Applescript ObjC to send a URL referenced folder to the trash?
In 10.8 it's simple:
tell fileManager to trashItemAtURL_resultingItemURL_error_(theURL, missing value, missing value)
And deleting rather than moving to the trash is easy with all versions:
tell fileManager to removeItemAtURL_error_(theURL, missing value)
But moving to the trash pre-10.8 is a bit ickier:
tell fileManager to performFileOperation_source_destination_files_tag_(current application's NSWorkspaceRecycleOperation, theURL's URLByDeletingLastPathComponent()'s |path|(), "", {theURL's lastPathComponent()}, missing value) It's icky because it happens asynchronously, so if your code relies on the item having been trashed straight away, you could strike problems. This is especially the case with large folders.
But it looks like you just want to get rid of empty folders, so deleting might be the most useful. |