Sharing a vMix script a friend wrote.
The use case:
The List input of vMix, strangely and unfortunately enough, only sorts its file order by file name, and A-Z only (no option for Z-A etc.).
We need files in the list to be sorted Z-A, specifically:
time + date are in the filename and we need to play the newest / latest file (highest date, highest time) first.
Why? Because these are exports from vMix replay (with filename: date - text - time), and we play these back during breaks in the game.
We want to be certain that during these breaks, viewers see the most recent actions as replays. Starting with the most recent one and then going back in time, step by step, ensures this.
Playback of replay events in chronologically reversed order, so to say.
We use Elgato StreamDecks with Companion.
There is a button that first creates the replay event, with a second action on that same button to export the event as an .avi file.
There must be an list input in your vMix project that is called List.
Every time the script is called (we have it behind a keyboard shortcut),
it clears the existing files from the list, populates the list with all avi-files in the specified folder,
sorts these by date/time descending (date/time are taken from file NAME),
and transitions that list (in our case, the list is on input 94) to PGM Out, using Stinger2.
The list has "Auto Next" on.
The list input (94) has a Trigger on it:
OnCompletion - Stinger2 - 1.Main
which means that when the entire list has played, Stinger2 transitions input 1 (Main camera) into PGM Out,
effectively moving the list into Preview.
The longer the list grows, the greater the chance our director transitions out of it manually, before it has completely played.
<start of the script>
'Script to sort the files on a part of the filename,
'instead of filename itself
'This script sorts files on the relevant time part in the filename
'e.g. "20221210 - Camera4 - [21-32-10] [21-32-15].avi"
Dim relevant_character as string = "["
Dim unique_separator as string = "|"
Dim p As String = "D:\vMix-IRP_D\replays\"
Dim di As New system.IO.DirectoryInfo(p)
Dim fa as system.io.fileinfo() = di.getfiles("*.avi")
dim fi as system.io.fileinfo
Dim cnt as integer = fa.Length
Dim sa(cnt) As String
Dim i as integer = 0
Dim x() as String
for each fi in fa
'split the filename on the relevant part to sort on;
'substring can also be used of course
x = fi.Name.Split(relevant_character)
sa(i) = x(1) & unique_separator & fi.FullName
i += 1
i = 0
dim s as String
dim f as String
for each s in sa
'for some reason, does the sorted array have an extra empty element?
if s = Nothing
'split the value on the unique_separator to get the original filename
x = s.Split(unique_separator)
i += 1
<end of the script>
Please feel free to use, modify, improve, elaborate, comment.