Button with Condition on File Type

I'm thinking of creating a button that toggles the dimension column if an image is selected, and the duration column if a movie is selected. Not even sure that's a good idea, but wanting to try it (the words dimension and duration share the letter D, so that's one less shortcut to remember.)

Since I couldn't find a command of the form @iftype, the closest I could think of would be to use @pathr

This is what I came up with, but the button doesn't work. Would someone please point me in the right direction?


@ifpathr:\.(?:jpe?g|gif|bmp|tiff?)$
Set COLUMNSTOGGLE=picsize(3,*)
@ifpathr:\.(mkv|avi|mp\d|flv)$
Set COLUMNSTOGGLE=mp3songlength(3,*)

@ifpathr tests the path the lister is in, not any selected file paths.

@hidenosel is more what you want. You could have two buttons, set to hide themselves unless the appropriate types are selected. (So both buttons would be hidden if nothing from either type is selected.)

Or you could use @disablenosel to disable a button instead of hiding it. You'd probably then want to make it a script button so you can do conditional logic depending on what is selected, if you don't want to have two buttons and hide one or both based on the file selection.

Hi Leo,

Greetings from Glasgow (same timezone as you for once?)
I really appreciate your thoughts! They broadened my perspective on various ways to do this.

After weighing the pros and the cons, I decided that the most rewarding would be to write a script button to do exactly what I want, depending on the types of files in the tab.
I posted the complete button here. It was a nice exercise for me as I haven't played enough with button scripting, and I had started to collect some bits and pieces to write a beginner page about it some time this year.

Thanks again, wishing you a beautiful day.

1 Like