You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We could do it in-process, because you can call AppleScript from Cocoa too, but I'm not sure it's worth the effort - unless it's trivial to call Cocoa from .NET Core - I have not looked into it.
Let me add that Clear-Trash should be an effective alias of Clear-RecycleBin so as to support familiar terminology on Unix-like platforms and use a generally more apt real-life metaphor, as discussed at the top of #6778.
Currently we haven't Clear-RecycleBin in PowerShell Core and we could rename it to Clear-Trash
With #5870 in mind, an alias could be added to Windows PowerShell.
So a couple things. The finder supports directly emptying the trash. Single command: tell application "finder" to empty. so a call to osascript -e works there
Since the cocoa frameworks allow moving to trash easily, i'd use them, as using osascript -e for that gets a little weird since you have to have a file object which you then use in: tell application "finder" to move to trash. You can play some games with posix file et al, but any time the frameworks will do it, that's the better way to go.
Activity
[-]Need port Clear-RecycleBin cndlet[/-][+]Need port Clear-RecycleBin cmdlet[/+]mklement0 commentedon May 2, 2018
Let me add that
Clear-Trashshould be an effective alias ofClear-RecycleBinso as to support familiar terminology on Unix-like platforms and use a generally more apt real-life metaphor, as discussed at the top of #6778.iSazonov commentedon May 2, 2018
Currently we haven't
Clear-RecycleBinin PowerShell Core and we could rename it toClear-TrashWith #5870 in mind, an alias could be added to Windows PowerShell.
johncwelch commentedon Nov 18, 2020
So a couple things. The finder supports directly emptying the trash. Single command: tell application "finder" to empty. so a call to osascript -e works there
Since the cocoa frameworks allow moving to trash easily, i'd use them, as using osascript -e for that gets a little weird since you have to have a file object which you then use in: tell application "finder" to move to trash. You can play some games with posix file et al, but any time the frameworks will do it, that's the better way to go.