Fail-over function

Would you like Bulk Rename Utility to offer new functionality? Post your comments here!

Fail-over function

Postby TheGhost78 » Tue Nov 18, 2025 3:02 am

I want to perfix video file names with the Encoded Date - but not every file has that field in the metadata. In those cases, I want to use the Created Date field. It would be good to do this in a single pass. So, can a symbol be added to allow for a fail-over function, 'If blank use next', using a symbol such as £.
E.g.
Add (7)
Prefix: <($MediaInfo:Encoded_Date)>£<($MediaInfo:File_Created_Date_Local)> -
or maybe
Prefix: <($MediaInfo:Encoded_Date)£($MediaInfo:File_Created_Date_Local)> -

If both fields are populated, use only the first field's value and disregard the second field's value.
TheGhost78
 
Posts: 246
Joined: Fri Jul 19, 2024 11:25 am

Re: Fail-over function

Postby Admin » Tue Nov 18, 2025 5:21 am

Hi,

Currently, use the JavaScript renaming engine (one-pass) to test the two metadata fields and pick the first present value. This is exactly what you described and is easy to do. It also lets you format the date consistently.

If you must avoid scripting: there is no built-in “failover-within-a-single-tag” operator. The {default:...} formatter exists but its argument must be literal text (you cannot put another tag inside it), so it cannot be used to call a second tag as a fallback. Could be an improvement for the future.

Example JavaScript solution
1) Make sure you have MediaInfo support installed (MediaInfo DLL) so the MediaInfo tags are available.
2) Open Special (14) -> Javascript Renaming and paste a small script like this:

Code: Select all
// get Encoded Date (MediaInfo) or fall back to file created date
var d = filePropertyDate("MediaInfo:Encoded_Date") || filePropertyDate("MediaInfo:File_Created_Date_Local");
if (d) {
    // format as YYYY-MM-DD (change pattern if you want time, etc.)
    var pref = formatDateTime(d, "YYYY-MM-DD");
    // choose separator you want, here underscore and dash example:
    newName = pref + "_" + name;
} else {
    // neither date present — leave name unchanged (or set some default)
    newName = name;
}


Notes and tips
- Change the formatDateTime pattern ("YYYY-MM-DD") to include time or different separators (example "YYYY-MM-DD_HH-mm-ss") if you want time too.
- If you want the date to be suffixed instead of prefixed, move the formatted date to the end: newName = name + "_" + pref;
- This runs in a single pass and only adds the first available date — exactly the failover behavior you asked for.
- If you need different formatting per-field (e.g., Encoded_Date has a different native format), convert each to Date and then format as you like (filePropertyDate returns a Date or null).
Admin
Site Admin
 
Posts: 3120
Joined: Tue Mar 08, 2005 8:39 pm


Return to Suggestions