Filename to releasetime - a little help?


#1

Hi, folks--forgive me my naivete, since I barely speak regex.

I have a lot of files--NPR stories, to be specific--where the filename begins with a 8-character string that is the release date in YYYYMMDD form. I'd like to create an action to insert this string into the releasetime field as MM/DD/YYYY so that I don't have to adjust each day's worth of files manually.

The filenames all look like this: 20171201_atc_the_disaster_artist_is_the_best_movie_about_a_bad_movie

Is this something that can be done? Thanks.


#2

Try
(Format action)
Format : RELEASETIME

$regexp(%_filename%,^([19|20]\d{2})(\d{2})(\d{2}).*,$2/$3/$1)

Or you could add this to a new column for easy sorting using (in the sort part of the new column ui)

$regexp(%_filename%,^([19|20]\d{2})(\d{2})(\d{2}).*,$2/$3/$1)

#3

Actually, the field RELEASETIME has the format
yyyy-mm-ddThh:mm:ssZ
So a transformation into MM/DD/YYYY would create an invalid releasetime.
If you want to get it right, then proceed as follows:
Create an action group with several actions as follows:

Format value for RELEASETIME
Format string: $regexp(%_filename%,^(\d+).*,$1)
This imports the leading number from the filename into RELEASETIME

Then insert the separators and a dummy time at the end:
Format value for RELEASETIME
Format string: $regexp(%releasetime%,(\d\d\d\d)(\d\d)(\d\d),$1-$2-$3T00:00:00Z)


#4

Thank you both--I'll give those a try!