regex to add text in a file name

A swapping-ground for Regular Expression syntax

regex to add text in a file name

Postby jmacp1808 » Fri Oct 24, 2025 3:50 pm

Hi
I have a huge amount of files which contain a date in the format DD-MM-YY, some of the files have DD-MM-YYYY.

What I would like to do if find the files with DD-MM-YY and then change them to DD-MM-YYYY so the filename would change like this.

James christmas 25-12-19
James christmas 25-12-2019

Thanks

John
jmacp1808
 
Posts: 1
Joined: Fri Oct 24, 2025 3:44 pm

Re: regex to add text in a file name

Postby Admin » Sat Oct 25, 2025 1:25 am

Two safe options in Bulk Rename Utility - RegEx (1) or Name(2) -> Reformat Date. Pick one below and test on a few files first (always keep a backup).

Option A - Use Name (2) -> Reformat Date (simplest)
1. Select the folder and highlight some files to test.
2. In the Name (2) panel set the drop-down to "Reformat Date".
3. In the Reformat box enter a rule that tells BRU how to interpret the existing date and how to output it. For your case use:
%d-%m-%y>%d-%m-%Y
This means: interpret a date that looks like DD-MM-YY and reformat it to DD-MM-YYYY.
4. Preview the New Name column (select files). Files named like
"James christmas 25-12-19"
should show as
"James christmas 25-12-2019"
Files already containing a 4-digit year (25-12-2019) will be left unchanged.
5. If the preview looks correct, click Rename.

Notes:
- This is the clearest approach because BRU's Reformat Date is made for exactly this kind of conversion.
- If your two-digit years include centuries other than 20xx, this will still prefix 20 (e.g. 99 -> 2099). Check your data before running on everything.

Option B - Use RegEx (1)
1. Select the folder and highlight files.
2. In RegEx (1) set:
Match: (\b\d{2})-(\d{2})-(\d{2})\b/g
Replace: $1-$2-20$3
- The /g flag tells BRU to replace all occurrences in the name.
- \b anchors to word boundaries so it targets standalone dates.
3. Make sure "Inc. Ext." is OFF (unless you intentionally want to include extensions).
4. Preview the New Name column. Example:
"James christmas 25-12-19.jpg" -> preview "James christmas 25-12-2019.jpg"
5. If OK, click Rename.

Warnings and tips
- Test on a small selection first. Use Preview - inspect many examples (beginning, middle, end of filename).
- Back up important files before doing a mass rename.
- If you have two-digit years that should map to 1900s instead of 2000s, you'll need a more complex rule (regex + conditional or manual handling).
- If you use RegEx, ensure you include /g if you want every occurrence changed (RegEx (1) replaces only the first match by default).
- If filenames contain other numeric strings that look like DD-MM-YY but are not dates, double-check your matches.
Admin
Site Admin
 
Posts: 3095
Joined: Tue Mar 08, 2005 8:39 pm


Return to Regular Expressions