"Select ALL" question

I have a button that selects all 44 byte files (trash files from a particular program I use), deletes them, and then selects all remaining files. When I run that button in a folder that has no 44 byte files, I would expect it to simply select all the files, because that's the last line in the button's code. But it doesn't do that, it doesn't do anything at all. It only does anything if there actually are 44 byte files in the folder. Why is that? Is there a way around it?

--chriscrutch

Can you post the lines from the button?

Sure, nudel. I'm on a non-Dopus equipped box right this second, so I can't give you the full button code, but the commands it runs are:

Select FILTER=RadioCrap
Delete QUIET
Select ALL

RadioCrap is a filter defined as "Size Match Is equal to 44 bytes."

--chriscrutch

It's the Delete command which is stopping the button if no files are selected.

Here's an alternative which works:

Delete FILE=* FILTER=RadioCrap QUIET
Select All

Don't be tempted to move the "Select All" above the delete. For some reason the filter is ignored if you do that. The FILE=* part means the Delete command will apply to everything regardless of what's selected so you still get the desired effect.

As always with Delete buttons, run this a few times on a test folder before letting it loose on any important files! I may have missed something in my tests.

Also, remember that the delete will also go into subdirectories and recursively delete files in them which match your filter. If you only want files in the immediate directory to be deleted you can add a SubFolder clause to your filter:

Why does the delete command stop the execution of the rest of the commands? I know that not all commands that do nothing will stop the execution of the button, so why does the delete command do that?

--chriscrutch

Update (did someone get rid of the "Edit" button?):

Nudel, your modified button didn't work for me either. Well, it worked, but if I use it in a folder where there are no 44 byte files, it still won't select all at the end. It's the same problem I had before.

There's nothing in Preferences that could be affecting this, could there?

--chriscrutch

Good point, I got carried away trying to solve one thing and forgot about the other.

I'm not sure why the command stops if nothing is deleted. Maybe there's a good reason for that and it makes sense in some other cases, but here at least it does seem like unwanted behaviour.

You might be able to use dopusrt to do the job... Try this button in a test directory and see what happens:

dopusrt /CMD Delete FILE=* FILTER=RadioCrap QUIET
dopusrt /CMD Select All

That did it. The button selects the 44 byte files, deletes them, and then selects all. When there are no 44 byte files, the button simply selects them all. Perfect! For some reason, using dopusrt did the trick. Thanks for that, nudel.

--chriscrutch

Yes. A number of users were asking questions then, once answered, changing their posts to either new questions/subjects or editing the meaning of the original. Making it difficult to follow threads and ruining the benefits of a topic based search.