Suppressing Display Of "Empty" Duration Values

Started by Darius1968, July 26, 2019, 08:20:14 AM

Previous topic - Next topic

Darius1968

This is my code to display File Size (on Line 1) & File Duration (on Line 2), in the "Size" Column of my "Grid" File Window Layout: 

<TextBlock Grid.Column="0" Grid.Row="0" TextWrapping="Wrap" Margin="5,0,5,0"><Run FontSize="11pt"> {File.Size} </Run></TextBlock> <TextBlock Grid.Column="0" Grid.Row="1" TextWrapping="Wrap" Margin="5,0,5,0"><Run FontSize="11pt"> {File.Duration.HMS|is:Yes,{File.Duration.HMS} ;is:No, ;} </Run></TextBlock>

It works fine as it is, but what can I do to suppress "00:00:00", for the case of non audio/video files?  Thanks. 

Mario

You can simple do a numcomp to check if the duration is 0. Then either show some output or not

{File.Duration|cast:int;numcomp:ne,0,Has duration,Has no duration}

in your case probably

{File.Duration|cast:int;numcomp:ne,0,{File.Duration.HMS},}

This shows the duration only when it is not 0.

The cast:int is required because by default variables return numbers formatted based on the current user's numeric formatting settings.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook