Tiles View - Script for Text?

Is it possible to add a script for Tiles in File Types?

I want when I'm watching folders in Tiles View, to read the duration of a video file inside each folder and show it next to the folder.

Yes, script columns can be added to tiles, and are automatically included in the drop-down list in the file types / tiles editor. I just did a quick test and it seems to work fine.

1 Like

So I was able to write a script that goes inside the folders and finds my .mkv file and I have it as an Item object. Now, how can I extract the duration information from that Item object?

Item.metadata.video.duration

1 Like

Wow, thank you. I can't believe I did it and it works. It's like magic. Now I can see the duration of movies without needing to go inside their folders.

There are still some things I need to learn and make better.

I used Item.metadata.video.duration but it returns it in secs and I was unable to format it. I have seen the help and that I have to use {modified|T#HH-mm-ss} but I don't know how to apply it in
scriptColData.value = eItem.metadata.video.duration;

Also I have to work how to do the sorting correct. For that I suppose I have to use metadata.video.duration. At the moment I'm using metadata.video_text.duration to get the format

I'm not sure what language you're using, but to e.g. format seconds as HH:mm:ss in vbscript, you can do something like this:

Function FormatSecondsAsTime(nSeconds)
	Dim nHour, nMin, nSec
	nHour = Int(nSeconds / 3600)
	nMin = Int((nSeconds Mod 3600) / 60)
	nSec = Int((nSeconds Mod 3600) Mod 60)
	FormatSecondsAsTime = LPad(nHour, 2, "0") & ":" & _
						  LPad(nMin, 2, "0") & ":" & _
						  LPad(nSec, 2, "0")	
End Function

Function LPad(s, l, c)
  Dim n : n = 0
  If l > Len(s) Then n = l - Len(s)
  LPad = String(n, c) & s
End Function

I'm using and modifying the "This column Is Modified?" example in the HELP.

It says // Set the script type to JScript to use this script
funny thing I never did set it to anything and it is still working.

I'm going to work on this tomorrow.

I thought there should be an easier quicker solution to format duration as is written here:
https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Keywords_for_Columns_Set_Command.htm

...using JScript.

The Opus Date/Time objects have Format methods:

I was unable to format it using .Format() applied to duration. It's surely not the right type and I have to dig deeper but I found another solution and it is easier. I do this

scriptColData.value = eItem.metadata.video_text.duration;
scriptColData.sort = eItem.metadata.video.duration;

Passed the sort value separately.

1 Like