Load all files in a particular folder named with a future date

You have a question or need an advice about how to do something? Ask it here!
polp6880
Posts: 36
Joined: 19 Apr 2020 19:04
Load all files in a particular folder named with a future date

Post by polp6880 »

Hi,

I'd like to set up a system to automatically air the daily announcements from a script as explained below.

We have a folder called Announcements and within that folder, the talent records daily announcements. Every day has its own set of announcements so for ease of use, the talent saves the recorded files in this format "YYYYMMDD.mp3".

I want to have a script that loads all the files in the Announcements directory that have today's date or a future date since files with a past date are not valid anymore.

My idea was to set these up using the filters functionality but I didn't manage. I first tried to use the LoadFolder entry type but I realized that I cannot apply filters to this entry type.

Then I added the Announcements folder as an item in Media Library (with Auto Watch) and tried to use the Sequential entry type with a count of 10 (so theoretically, I get all the files in that folder since we usually have a maximum of 7). I was able to set up filters here but I didn't manage to come up with the correct filter to use so only files with a present or future date are picked up. I tried "file is greater or equal than" the current date and some other variations of that but I always got all the files or none at all.

What would be a good filter to use for this? Or perhaps there's a better way for me to do this?

Thanks!
User avatar
radio42
Site Admin
Posts: 8295
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Load all files in a particular folder named with a future date

Post by radio42 »

First question is: it seems that with a file naming of YYYYMMDD.mp3 there can be only one file per day?! But in your explanation it doesn’t sound like that.
However a script or media library currently can not recognize invalid tracks based on its filename.

The other idea of yours sounds correct in general, but I need to test and probe why it shouldn’t work. But I am still not 100% sure about your desired result.
User avatar
radio42
Site Admin
Posts: 8295
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Load all files in a particular folder named with a future date

Post by radio42 »

Just tested it:
A possible filter might be Contains([Filename], '20210501') or Contains([Filename], '202105')

that works like a charm here.
polp6880
Posts: 36
Joined: 19 Apr 2020 19:04
Re: Load all files in a particular folder named with a future date

Post by polp6880 »

Hi Bernd - thanks for your quick response and for testing.

I will try what you suggested but below, I'm going to explain what I'd like to do in a bit more detail...

I have an "Announcements" folder and in it, let's say that I have the below files (ie one file for each day):

- 21210601.mp3
- 21210602.mp3 ---> this is today
- 21210603.mp3
- 21210604.mp3
- 21210605.mp3
- 21210606.mp3
- 21210607.mp3

Let's say today is 2nd June 2021. What I'd like to achieve is to have a script that loads all of these files:

- 21210602.mp3
- 21210603.mp3
- 21210604.mp3
- 21210605.mp3
- 21210606.mp3
- 21210607.mp3

Meaning that the script loaded today's file and all the other files that have a "future" date but omitted the file with a past date (ie 21210601.mp3) Basically, it's ok for us to air present and future announcements but "past" announcements would need to be skipped as the information in them would be expired.

From a quick look, it seems that your example is set to load either a specific date file (20210501) or the files for a particular month (202105).

Hopefully, this better explains.

Thanks!
User avatar
radio42
Site Admin
Posts: 8295
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Load all files in a particular folder named with a future date

Post by radio42 »

Thanks for the explanation. Now it is clearer.
Currently the ‚Filename‘ field will also contain the full path. That’s why you can’t use it with any function macros or real compare operators.
But in the next version I’ll add a ‚FilenameOnly‘ field with which you can do all that!
polp6880
Posts: 36
Joined: 19 Apr 2020 19:04
Re: Load all files in a particular folder named with a future date

Post by polp6880 »

Hi Bernd,

That would be awesome - thanks!
polp6880
Posts: 36
Joined: 19 Apr 2020 19:04
Re: Load all files in a particular folder named with a future date

Post by polp6880 »

Hi all,

I can see that the FilenameOnly option has been added to the latest version. Thanks for that!

Would you please be able to show me exactly what steps I need to follow to set a script that works as I mentioned above? I tried several times but it seems that I'm missing something as I'm either getting all the files in the directory or none.

Thanks!
User avatar
radio42
Site Admin
Posts: 8295
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Load all files in a particular folder named with a future date

Post by radio42 »

You as I explained above.
I.e. you create a media lib (e.g. a simple folder based) which contains these files and optionally set the Sorting to Filename.
You then create a script with e.g. this scriot-line:
Sequential, /yourmedialibname, Count=5, Options=SuppressHistoryCheck,..., Filter=~[FilenameOnly] >= '${yyyy}${MM}${dd}.mp3'

That's it. Note, that you can click on the 'Test...' button to test the Filter resp. even the entire Script.
polp6880
Posts: 36
Joined: 19 Apr 2020 19:04
Re: Load all files in a particular folder named with a future date

Post by polp6880 »

Hi Bernd,

I tried this but it seems that I still can't manage to make it work the way I want it to.

This is the script line I have: https://share.getcloudapp.com/d5uRew15
This is the filter set: https://share.getcloudapp.com/wbubk9wR

When I test, however, the script is returning all the files: https://share.getcloudapp.com/E0ujE9jr (the files in the red box should not display since today is "20210814".

For reference, this is the list of files in the folder/media library: https://share.getcloudapp.com/geuAr4AE

Could you please check what I could be doing wrong?

Thanks!
User avatar
radio42
Site Admin
Posts: 8295
Joined: 05 Apr 2012 16:26
Location: Hamburg, Germany
Contact:
Re: Load all files in a particular folder named with a future date

Post by radio42 »

In general it looks good what you are doing - and exactly as I tested it.

So maybe you better use the Script ‘Test…’ function. You might then send me the output text of the test result - that should show the reason, why all tracks are shown.

Post Reply