Home » Blog
date 6.Feb.2025

■ Extract movie year information from filenames


ID3 tags are generally ok for music files. However the equivalent EXIF metadata for films are almost non-existent — including Year, Directors and such. If you enable such file details for MP4/AVI/MKV and assorted video files, they come up empty. So how can you e.g. find old movies by year?

Certainly you cannot do it by generic file date information. Creation and modification dates relate to the file, not the original movie. The file column Media created likewise only exists for videos you have shot with your phone or camera, not a film you have downloaded.

Here is a possible workaround for year information. Many downloaded movies include the film year in the filename (in brackets or otherwise) as such:

Star Wars The Empire Strikes Back (1980) 720i.mkv
Brazil.1985.720p.X264.mp4
WarGames 1983.mp4

Obviously there's no guarantee that year is part of the filename, but if you can find 4 digits somewhere in the name, it usually is the desired information. So we just need to extract 4 numbers from a filename, that can appear anywhere (start, middle or end of name). A tall order you say? Not really, it is quite easy using xplorer² programmable file properties. Use Customize > Programmable > Add new menu command and type in the following definition:

INT( MID(${Name}, FIND(${Name}, '\d\d\d\d'), 4) )

For years its more robust to use this regular expression that excludes non-year 4-digit numbers '[12]\d\d\d'

This complex expression searches for 4 numbers in ${Name} using FIND function ('\d\d\d\d' is a regular expression that matches 4 digits exactly). If the search is successful, it extracts the 4 digits using MID function. Finally the text is converted to an integer number using INT function.

Converting to integer isn't required but it helps if you want to search for a range of years

movie year property in action

The complex recursive expression can broken down to its constituents so that it is easier to digest, unwinding the inner function calls using intermediary variables. (// are comment lines)

Note how regular expressions are defined using single ears '\d\d\d\d'

// suppose the current filename is "WarGames 1983.mp4"
n = FIND(${Name}, '\d\d\d\d')   // n=10, the offset where the 4 numbers start
str = MID(${Name}, n, 4)        // extract 4 letters from position n (str="1983")
year = INT(str)                 // 1983 is the end result

Some assembly required <g>

Post a comment on this topic »


©2002-2025 ZABKAT LTD, all rights reserved | Privacy policy | Sitemap