Cycle Dimensions & Duration Columns (depending on files in tab)

TLDR;
Please Watch the DEMO VIDEO in the next post!
(-:

This button scratches this itch: when I have audio, video or image files, sometimes I want to see the dimensions (image or video files) or the duration (audio or video files). Both dimensions and duration start with the letter d... And I like the idea of a magic button, called with a single shortcut (say Ctrl + Alt + D) to show or hide the columns as appropriate.

Expected Behavior

  1. If the tab has no audio, video or image files, remove the dimensions and duration columns if they were present.
  2. If the tab has 'dimension carrier files' (image, video) but no 'duration carrier files', toggle the dimensions column.
  3. If the tab has 'duration carrier files' (audio, video) but no 'dimension carrier files', toggle the duration column.
  4. If the tab has both 'duration carrier files' and 'dimension carrier files', cycle between four states:
  • both dimensions and duration OFF
  • both dimensions and duration ON
  • duration ON, dimensions OFF
  • dimensions ON, duration OFF

A debug mode (set to false by default) is provided so you can see what's going on.

Disclaimer, Feedback
This is one of my first experiments with button scripting, so if you see ridiculous things or better ways to do things, please let me know. For other beginners, I have commented the more obscure parts of the code (those introducing the Opus objects) so you can easily follow along.

Thanks in advance for your thoughts!

Edits:

  • change cycling order
  • use clickData built-in Command object instead of creating via DOpusFactory

Cycle Dim Dur Columns.dcf (9.2 KB)

1 Like

A picture is worth a thousand words, so here is a VIDEO showing what the button does. Notice the different action depending on the mix of file types in the tab (audio, video, image).

Dimensions Duration Button.zip (24.7 MB)

I love it! Thanks for sharing! I always wanted to tackle this myself tho I am not good at scripting - so thank you very very much!

Glad it helped. :- )
Wishing you a great day.