How do I enumerate files in the Recycle Bin?

The following totally unremarkable button-JScript snippet enumerates files and folders in every folder except the Recycle Bin. When applied to selected files and folder in the Recycle Bin, however, aFiles remains a zero-length array:

var aFiles = new Array var nn = 0 var oFiles = new Enumerator (ClickData.func.sourcetab.selected) oFiles.moveFirst () while (!oFiles.atEnd ()) { aFiles [nn] = oFiles.item () nn++ oFiles.moveNext () }QUESTION: How do I change the code so that it enumerates files and folders in the Recycle Bin as well?

I've just read GeekDrop's post Getting Selected File Count (jscript) immediately below, and verified that:

DOpus.Output (ClickData.func.sourcetab.stats.selitems)returns the number of selected items everywhere except in the Recycle Bin. Same problem, of course, but how should I change the code so that it works with selected files in the Recycle Bin as well?

Try this:


function OnClick(data) {
var objShell;
objShell = new ActiveXObject("Shell.Application");
var recycleBin = objShell.NameSpace(10);
var items = recycleBin.Items()
var tab = data.func.sourcetab;
var count = tab.selstats.selfiles;
if (tab.path == "::{645FF040-5081-101B-9F08-00AA002F954E}")
DOpus.Output (items.count);
DOpus.Output (count);

Thanks, Kundal — those details are new to me. They solve my associated problem of how to test whether the source is the Recycle Bin or not, and using that vital clue, I can now construct a satisfactory workaround for what I am doing at the moment.

But 'items.count' in your script gives the total number of all files in the Recycle Bin, whereas I want to deal only with the selected files. I know that even when the source is the Recycle Bin, DOpus knows very well what files have been selected, because very simple DOpus commands such as "Copy" only act on those selected files. My question is:

  • How do I manipulate those selected Recycle Bin files within JScript, because the usual enumerator methods fail.

You may not be able to with the Recycle Bin as it is an Explorer window really.

Thanks, leo, for confirming that DOpus scripts dealing with selected files won't necessarily work in the Recycle Bin. I've sorted things out a different way using Kundal's code snippet.

But this unfortunately brings up a further related question about security and privacy:

  • Does the DOpus command 'Delete Secure' work on files in the Recycle Bin? It seems to run too quickly for overwriting to occur.
  • If not, can DOpus securely delete Recycle Bin files some other way, or should CCleaner be used for this purpose?

Delete Secure has no effect on the Recycle Bin, other than to pass a normal "delete" command through.

If you want to use a secure delete, I'd recommend not using the recycle bin in the first place, since it's designed to do the opposite and may cause additional tracking (at least of filenames, if those are sensitive).

I can't comment on CCleaner as I don't use it.

Thanks again, leo, for clarifying that point about 'Secure Delete', and for the very good advice about deciding before deleting files. (According to Piriform's website, once the files are in the Recycle Bin, the situation with CCleaner is a little complicated because it involves using Recuva as well --- Eraser seems to provide a more straightforward approach.)