GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Archives only view toggle button

This is a simple button I created to speed up a task I do regularly. It's job is simple, to view all archive files in your current folder and all of it's sub directories. It will hide anything that isn't an archive including folders. For those who have many archives spread out in many sub directories, this will make managing them in bulk fast and easy. No longer do you have to create a batch script that's made for a specific folder and purpose.

It should be noted that this can be adapted to work exactly the same with any filetype by changing the extensions it looks for.

** Update **

Button has been updated to preserve prior filter settings when toggled off.
Condition check for seeing if the button had already been clicked has been improved.

Archives only.dcf (1015 Bytes)


@if:Set SHOWFILTERFILENAME="*.(zip|rar|7z|arj|bz2|bzip2|cb7|cbr|cbz|gz|gzip|lha|lzh|lzma|lzma86|r00|r01|tar|taz|tbz|tbz2|tgz|tlz|tlzma|tpz|txz|xz|z)"
Set FLATVIEW=off
Set FORMAT "zz[temp]"

@if:else
Set SAVEFORMAT=favorite FORMAT "zz[temp]"
Set SHOWFILTERFILENAME="*.(zip|rar|7z|arj|bz2|bzip2|cb7|cbr|cbz|gz|gzip|lha|lzh|lzma|lzma86|r00|r01|tar|taz|tbz|tbz2|tgz|tlz|tlzma|tpz|txz|xz|z)"
Set HIDEFILTERFOLDERS=*.
Set FLATVIEW=On,MixedNoFolders
@toggle:invert

Instead of including all the archive extensions in the button, you can probably simplify that line to this:

Set SHOWFILTERFILENAME=grp:Archives

That's assuming all the extensions (that you care about) are included in your Archives file type group.

Thanks for the tip Leo. I actually excluded some extensions like .cab and .iso as they would crowd the lister with unintended results. .cab are almost exclusively used for installers like DirectX for example. .iso didn't make much sense when looking for archives.

It's definitely good to know that you can filter by groups like that.

I'm not 100% sure about many of the more esoteric extensions so if you could point out any others that wouldn't make much sense for this use case it would be a big help.

Also wondering, is it possible to store your current showfilterfilename and hidefilterfolders in a variable before the button applies it's own and then restore those when toggling the archives only off?

If I'm reading the DO reference correctly I would do something like

@set SFFN=SHOWFILTERFILENAME
@set HFF=HIDEFILTERFOLDERS

Then to after the user is done with the archive only view, they would call the variables like this?

Set SHOWFILTERFILENAME={$SFFN}
Set HIDEFILTERFOLDERS={$HFF}

Scripts have access to the filter bar's current settings and would be able to do that.

Re esoteric archive types, whichever you don't use. For me that'd be everything other than zip, rar and 7z. For you it might be different. Only you can really answer that.

Thanks Leo!

I seem to be having trouble finding how to access the current hide folder filter and show folder filter in the scripting reference. All I'm looking to do is to gather the value of the these two before the script changes them and then restore them once the user toggles them off. I have this so far

@set SFFN={SHOWFILTERFILENAME}
@set HFF={HIDEFILTERFOLDERS}

@if:Set FLATVIEW=On
Set CLEARFILTERS
Set FLATVIEW=off
Set SHOWFILTERFILENAME={$SFFN}
Set HIDEFILTERFOLDERS={$HFF}

@if:else
Set SHOWFILTERFILENAME="*.(zip|rar|7z|arj|bz2|bzip2|cb7|cbr|cbz|gz|gzip|lha|lzh|lzma|lzma86|r00|r01|tar|taz|tbz|tbz2|tgz|tlz|tlzma|tpz|txz|xz|z)"
Set HIDEFILTERFOLDERS=*.
Set FLATVIEW=On,MixedNoFolders
@toggle:invert

I just need to know how to get a script to pass along showfilterfilename and hidefilterfolders.

They're available in the Format object.

Ah I see, scripting in opus isn't as simple as creating a function and calling that function using a DOPus internal command. I have to rewrite the entire script. Is there any way to get intellesense for scripting? Either though the in program editor or a different IDE like visual studio?

There may be an easier way to do what you're trying to do. You can use the Set SAVEFORMAT command to save the current format as a favorite, and then the Set FORMAT command to apply a favorite format to the current display. You could try something like this:

@if:Set FLATVIEW=On
Set FLATVIEW=off
Set CLEARFILTERS
Set FORMAT "Temp Format"

@if:else
Set SAVEFORMAT=favorite FORMAT "Temp Format"
Set SHOWFILTERFILENAME="*.(zip|rar|7z|arj|bz2|bzip2|cb7|cbr|cbz|gz|gzip|lha|lzh|lzma|lzma86|r00|r01|tar|taz|tbz|tbz2|tgz|tlz|tlzma|tpz|txz|xz|z)"
Set HIDEFILTERFOLDERS=*.
Set FLATVIEW=On,MixedNoFolders
@toggle:invert

That should work. Good idea using a format to save and then reload the prior folder format settings.

Yep, this worked perfectly. I made 2 changes to improve it a bit more as well. The format name is now zz[temp]. This is so that it will always appear at the bottom of the favorites list (out of the way) and it's a common name that can be used by other buttons should the need arise.

I also changed the if condition to the showfilterfilename. This should prevent any conflicts with folders that already have flatview set to on. I can't think of any instance where it would now conflict with another folder format or setting outside a button that does the same thing.

1 Like

Thank you for this button.

This almost does what I'm looking for except for one thing.

How can I make it so instead of applying the effect to the current folder, It goes first to a specified folder before doing the rest this code is doing.

I know I have to include a GO Path Command somewhere, that's my guess, but I really dont exaclty where in the code to put it or if there's a better way.

Thank in advance for your help

BTW, First Post here. LOL

=== EDIT 1 ===

I know this would go into sub-folder's I wanted to explain better that I meant to define the starting folder before the button does its action.

== EDIT 2 ===

If I add to the Begining the following

Go PATH="C:\Users\Name\Documents\Graphics Work"

It works as I want but with a small issue.

The button will stay like if its toggled.

This is what I have Right Now

Go PATH="C:\Users\Name\Documents\Graphics Work"
@if:Set SHOWFILTERFILENAME="*.(afdesign|afpub)"
Set FLATVIEW=off
Set FORMAT "zz[temp]"

@if:else
Set SAVEFORMAT=favorite FORMAT "zz[temp]"
Set SHOWFILTERFILENAME="*.(afdesign|afpub)"
Set HIDEFILTERFOLDERS=*.
Set FLATVIEW=On,MixedNoFolders
Set VIEW=Thumbnails
@toggle:invert

Remove the @toggle:invert from the end and the button won't appear permanently "on" anymore.

You could also use @toggle:if Set SHOWFILTERFILENAME="*.(afdesign|afpub)" if you want it to appear active in one state and not in the other.

Or you could move the Go ... command inside the two @if:... blocks, so the default toggled state is based on the @if line instead of the Go line.

1 Like

I'll try that as soon as I go back to my pc ... thanks for the time

@toggle:if Set SHOWFILTERFILENAME="*.(afdesign|afpub)"

That one did the trick. Thanks

You want

Go PATH="C:\Users\Name\Documents\Graphics Work"

to be inside the if:else statement. If you don't put it inside, it will apply the above argument every time you click the button, meaning the toggle function will not work. Like this

@if:Set SHOWFILTERFILENAME="*.(afdesign|afpub)"
Set FLATVIEW=off
Set FORMAT "zz[temp]"

@if:else
Go PATH="C:\Users\Name\Documents\Graphics Work"
Set SAVEFORMAT=favorite FORMAT "zz[temp]"
Set SHOWFILTERFILENAME="*.(afdesign|afpub)"
Set HIDEFILTERFOLDERS=*.
Set FLATVIEW=On,MixedNoFolders
Set VIEW=Thumbnails
@toggle:invert

In this example you can also keep the @toggle functionality.

1 Like

Thank you, Not only for providing the code sample but also because in doing so you helped me learned a little bit more about it with your explanation.

This one works perfect and also retain the @toggle functionality.

This helps me a lot when I need to open an Affinity file by looking at the thumbnails all at one instead of trying to remember their names.

Having a button that does that with one click really saves me a lot of time.

1 Like

Happy to help! I'm glad people are finding my code useful.

1 Like

Really great script and just like @Lare2 describes it is great to see a way to work with filters. Thank You