Skip to content

Need port Clear-RecycleBin cmdlet #6778

Closed

Description

@iSazonov

We need port Clear-RecycleBin` cmdlet.

We already have Clear-RecycleBin code for Windows but we should fix issue #6743.
On Linux and MacOs we should implement the cmdlet.

Related links from Electron

MacOs API https://developer.apple.com/documentation/foundation/nsfilemanager/1414306-trashitematurl?language=objc

From mklement:

However, the Cocoa Foundation framework only supports moving an item to the trash, it doesn't support emptying the trash.

Hence my suggestion to use command-line utility osascript with a piece of AppleScript for simplicity.

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.

Activity

  1. changed the title [-]Need port Clear-RecycleBin cndlet[/-] [+]Need port Clear-RecycleBin cmdlet[/+] on Apr 30, 2018
  2. mklement0 commented on May 2, 2018

    @mklement0
    Contributor

    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.

  3. iSazonov commented on May 2, 2018

    @iSazonov
    CollaboratorAuthor

    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.

  4. johncwelch commented on Nov 18, 2020

    @johncwelch

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions