Skip to content

gibosio/Remove-Safe

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Remove-Safe

License: GPL v3

Remove-Safe is a PowerShell module that provides a safe alternative to Remove-Item. Instead of permanently deleting files and folders, it moves them to the Recycle Bin.

Features:

  • Supports wildcards (*, ?)
  • Recursive folder deletion (-Recurse)
  • Handles hidden and system files (-Force)

Installation

Clone the repository or download the files:

> git clone https://github.com/gibosio/Remove-Safe.git
> cd Remove-Safe\Remove-Safe

Copy the module to a folder included in your $env:PSModulePath, for example:

> $target = "$env:USERPROFILE\Documents\PowerShell\Modules\Remove-Safe"
> New-Item -ItemType Directory -Force -Path $target
> Copy-Item -Recurse -Path .\* -Destination $target

Then import the module:

> Import-Module Remove-Safe

Verify that it loaded correctly:

Get-Command -Module Remove-Safe -CommandType All

You should see both the function Remove-Safe and its alias trash.


Usage

The main command is:

> Remove-Safe -Path <Path> [-Recurse] [-Force]

You can also use the alias:

> trash <Path> [-Recurse] [-Force]

Parameters

  • -Path
    One or more paths to move to the Recycle Bin. Supports wildcards (*, ?) and comma-separated lists.

  • -Recurse
    Removes a folder and all its contents recursively.

  • -Force
    Includes hidden and system files.

  • -WhatIf -Confirm


Examples

Remove a single file:

> Remove-Safe .\file.txt

or

> trash .\file.txt

Remove multiple files:

> Remove-Safe file1.txt, file2.txt
> trash file1.txt, file2.txt

Remove a folder and all its contents:

> Remove-Safe C:\ToBeDeleted -Recurse
> trash C:\ToBeDeleted -Recurse

Use wildcards:

> Remove-Safe C:\tobedele?ed*
> trash C:\tobedele?ed*

Notes

  • Folders specified without -Recurse will not be removed unless the option is explicitly provided.
  • If a path does not match any file or folder, a warning will be displayed.
  • If an item cannot be moved to the Recycle Bin, a warning will be shown.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.


License

This project is licensed under the GNU GPL v3. See https://www.gnu.org/licenses/gpl-3.0.html for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published