This tutorial explains how to delete files deleted from command line to Recycle Bin or Trash. In MS Windows and other operating systems, when you delete a file from command line, it gets deleted permanent. The delete operation from command line works in the same way as Shift+Delete works in Explorer. Unfortunately, there is no way to prevent that except by using some other external tools and utilities. Trash-Cli is a command line tool which can help you with that. It adds a new command on your PC to delete files and folders. And everything that you delete through this utility, sent directly to the Recycle Bin in Windows and Trash folder on MAC and Linux.
Trash-Cli is a powerful file deleter tool that you can use on any platform. You can delete multiple files and folders through it by using a simple command. Not only that, but it supports wildcards too. So, if you want to delete specific type of files from current folder then you can do that. You can easily install this tool on whatever platform you are running and use it in place of “rm” or “del” command when you don’t want to delete files permanently.
How to Send Files Deleted from Command Line to Recycle Bin or Trash?
Trash-Cli is an open source tool and relies on Node.js. You can install it through the Node package manager and then you can use start using it right from console. To install it, simply run the following command on your PC. It will hardly take a few seconds in installing and adding this utility to the “PATH” environment variable.
npm install - global trash-cli
Now, when you have installed it, you can start using it. The syntax for deleting files through this utility is same as the conventional delete command. You just have to replace that with “trash”, see below.
trash file1 file2 file3
You can use wildcards as well with this file deleter tool. You can easily use this tool to delete specific type of files painlessly. See the below example, in which it deletes all PNG files in the folder.
trash *.png
This way, you can easily use this command line tool to delete files but not permanently. While deleting all files in a folder, if you want to skip some file then you can specify its name and add “!” in the beginning. Also, if you are advanced Linux user then you can even use this tool by running “rm” command with the help of aliases.
Final thoughts
Trash-Cli is no doubt is an amazing tool which you can use to safeguard the “rm” and “del” command. If you accidentally delete lot of files while using command line then you will find this tool really helpful. If you still delete some files by mistake then you can use some recovery software as well.