What is the command line way of sending files to the recycle bin?
CmdUtils has a utility called Recycle
that does exactly that. [direct download]
More info:
To use the recycle command download the CmdUtils zip file and unzip the exe to your Windows folder. Adding them to the Windows folder would allow you to access the command globally without you having to specify the entire path to the executable. You can then start using the recycle command by typing in;
recycle filename.txt
You can also specify wildcards with the commands so typing in recycle *.txt will recycle any text files in the current directory. There is also a option to suppress the delete confirmation dialog by using the force flag with the command.
To delete a file without having to confirm is use the command
recycle –f filename.txt
The –f flag will tell the command to force a recycle without showing you the confirmation dialog.
If you have powershell installed:
$sh = new-object -comobject "Shell.Application"
$ns = $sh.Namespace(0).ParseName("PATH\TO\FILE\TO\DELETE")
$ns.InvokeVerb("delete")
There is no built-in way to do this, but there are third-party tools that can. I checked my program-dump folder and found a few options. They all work the same (e.g., recycle filename.ext
), but they vary in performance, so it depends on what your needs are (e.g., are you recycling a lot of files?)
- MaDdoG Software’s Recycle is fast and has no output, but can throw a mysterious not-found error
- EasyTools’ DeleteXP is slow because it displays the progress to the console, but if you redirect it to
nul
, then it is the fastest and reliable - Chris Yuen’s cmd-recycle is slowest, even when redirecting the (poorly formatted) output to
nul