Problems With Delete Filter Command

I've been trying to create a delete button that deletes all of the folders and subfolders (i.e. recursively) that are named target. In the past I've used PowerShell for something like this, but in this case Directory Opus is preferable to me because it can handle deletes of folders that exceed the 256 character path limit.

Anyway, I had been just using a filter to find them and then when the search results came back I would delete them, but this was a two step process and I do this fairly often so I figured why not create a button. I found this article: [url]Delete contents of sub folders from main folder] where it details a similar delete button, as well has using the help docs, but for some reason I'm finding weird results.

So this is what I have...
I created the following filter (note this filter correctly finds exactly what I'm looking for when I run it through find):

And then I created a button with the following function line (note I have tried with and without the *):

Delete FILTER "targetDirFilter" {sourcepath$}\*

But when I run it, it doesn't do anything. So I started playing with it a bit...

If I disable both of the filter conditions and run the button it deletes all files and leaves all folders in my source lister even though as far as I understand, it should delete everything in the source lister. So I know that the button works to some extent but even when it does something it isn't what I expect.

If I re-enable the filter conditions and change the button syntax to bypass the recycle bin (which I eventually want to end up with since I don't want all of the junk in the recycle bin):

Delete NORECYCLE FILTER "targetDirFilter" {sourcepath$}\*

It deletes all of the folders indiscriminately and leaves all of the files regardless of the conditions set in the filter.

Can anyone shed some light on this? Maybe there is an easier way to have one button/hotkey that uses Directory Opus to delete all folders/subfolders named target?

What happens, if you leave out the whole {sourcepath$}* bit?

The effect is the same as it is with the {sourcepath$}* only I have to make a selection in the source lister before the button will activate and allow me to push it.

When delete-filtering, a folder will only be deleted if it is empty.

The filter you are using won't match any of the files (or sub-folders) below the "target" folders, so only "target" folders which are already empty will be deleted.

I guess you want a filter like this:

SubClause

  • Type matches: Folders Only
  • AND: Name matches: target
    OR: Location matches, wildcard: /target(|/)

Leo, what you said makes a lot of sense to me, however, I feel like I can't even test this at this point because of the weird results that are happening. Maybe you could explain the results that I'm getting if I'm specific about what I'm encountering? It almost feels like a bug, either that or I am really off track with what I'm trying.

Here is my specific scenario:

I have the following folder tree:
ROOT
->mytest (folder)
->mytest2 (folder)
-->target (folder)
->target (folder)
-->testDoc.txt
->target.txt
->testDoc.txt

Here is my filter:

Here is my button:

After I click my button in my root my folder tree looks like the following:
ROOT
->target (folder)
->target.txt
->testDoc.txt

So it deletes every folder that does not have a file in it. Even deleting folders that have other empty folders in them regardless of their name. When what I expected, was the following tree:
ROOT
->mytest (folder)
->mytest2 (folder)
->target.txt
->testDoc.txt

Also, the other thing I can't figure out is that the button does absolutely nothing if I remove the NORECYCLE option.

Anything that is selected will be deleted regardless of the filter (unless they are non-empty dirs after the filter is applied). The filter only applies to things within selected folders, not things that are themselves selected.

I really appreciate the your time and the response Leo, but I'm not sure if I understand it.

I'm not actually selecting anything, in my case the button is looking at the source lister. I have no files or folders selected when I press the button.

Even if I had something selected, if it deletes folders regardless of the filter then what is the point of the filter?

I feel like what I want to do is simple. All I want to do is to permanently and recursively delete every subfolder named target within the active lister. Is there an easier way to do this?

Actually, ignore what I said about filters and the top-level/selected files; it's not true anymore. I was remembering a very old behaviour.

There might be a bug here. We'll look into it more and either get it fixed or explain what's happening.

Thanks so much Leo! Looking forward to hearing from you.

Any updates on this Leo?

Not yet. We'll update the thread and/or put a note in the release notes when we have anything.

It's been a couple of months, just wanted to check in and see if there has been any progress on this one?

I would still really like this feature and it has been more than 6 months since there was any reply or status update. Is there any progress towards a resolution for this?

Same answer as before, sorry. We haven't gotten to looking at this yet due to all the other work we've been doing.

The delete command will delete all selected folders as long as they're empty. The filter can be used to control which folders are entered as part of a recursive operation (via the Subfolder clause), and which files within the entered sub-folders are deleted, but it can't currently be used to control which folders are deleted. If a selected folder is empty (either to start with, or once its contents have been deleted), it will also be deleted.

We'll look at improving this in the future but for the moment I can't think of a good workaround unfortunately :frowning:

Thanks for the attention Jon, and while I'm bummed that DOpus can't help me with this, I'm grateful for the update.

Let me know if anything changes.