Command modifier to @hideifexists: Is this possible?

Hello, I am really interested in making certain buttons that will hide unless a certain file exists, say "cover.(jpg|png) in the current folder. I am at a loss of how to do this currently.

I am thinking I can run a @ifexists: and then set a variable to true if it is successful, and then have another modifier @hideif:$var=true as a second modifier, but I am unsure if DOPUS will process these in the given order.

Would love to know if there is a way to do this and, if not, if it can be added.

The variable @hideif tests would have to be set before the button is evaluated, not part of the same button.

You might be able to do it using a script add-in which sets a tab-local variable when you change folders. The documentation for @hideif doesn't mention variable support at all, though, so I'm not sure if that works there.

If the aim is to only show the button when in album folders, you could potentially use @hideifpath instead, if all your albums are below a certain place.

The issue is I have music organized in such a way that there is no way to use regex to get the folder path right every time. For video game music I organize by Video Game\[main console publisher|multiplatform]\[Remixes|Soundtracks|Compilations]\[Series|single albums]. With this naming scheme it could be as simple as "Video Game\Capcom\Ōkami Arrangement Collection Vol.1 Retro" or "Video Game\Multi-Platform\Remix Albums\Jake Kaufman\Shantae Half Genie Hero Soundtrack\Disc 1". And for everything else it can be Genre[Subgenre|Artist|Series] depending on certain things. There isn't enough conformity to detect via pathnames.

If you must know the button only contains this command: Rename FROM cover.png TO cover-large.png

It's intended for something I have to do to transfer my music to my portable media player. the huge fullsized raw PNG's take way too long to render compared to when I convert them to smaller JPG's (Which I have other buttons for). I made it as a quick "enter the folder, press the button, press ok if it doesn't have a png to convert. Made it a lot quicker than selecting the cover.png every time and manually doing it.

Music isn't the only case for this. I have a button that will automatically compile all Skyrim scripts in a folder which could be anywhere on various points in my PC (multiple HDD's), and it's wasting space in my menus unless it's needed (which is rare). There is no passing of filenames for this button. It takes a folder as an argument, thus if I could make the folder hide unless files with the specific extension exist in the folder, that would be heavenly.

That makes sense. Thanks for the detailed explanation!

One potential problem I can see is performance and/or how often it refreshes. e.g. Would it need to notice when the file was created/renamed/deleted? Or only check for things when a folder is loaded?


One thing you can do already is show/hide buttons (or right-click context menu items) based on the selected file/files' extensions. That would let you have the buttons hidden most of the time but appear when you select the cover.png file (or Skyrim script, etc.)

You could speed things up further with a hotkey which selects both things if they exist (or even a script that selects them automatically on folder change, although that could be dangerous if you don't notice they're part of the selection).

Hmm, you have a point. Having it check if a file exists every time you change a folder would put an overhead on it. I mean, I can set it up to do it when I select the files, but that's an extra click that I have to do tons of when I'm working on these things.

But no it would not need to read any metadata. Just check if the file by name exists once the folder loads. Having relative and absolute path options would be nice, but mainly it's the files inside the folder that opens that would be the biggest help. And of course letting you use patterns is really a must.

Perhaps this could be used in conjunction with hideifpath. Make it so hideifpath takes precedence, so if that is in the code it will not even process the hideifexists modifier, to save performance.

1 Like