Prefix Date in Reverse order from Name

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Prefix Date in Reverse order from Name

Postby mayakot98 » Mon Jul 21, 2025 8:42 am

Dear All,

Below is the screenshot of the original file and rename file date
https://prnt.sc/1dXpzBwlOryI

Example of original file name
JSBL-Stmt-10122024-008-XXXX081720000721_001.pdf

i used "Move/Copy Parts (6)" function to bring date at front from the name
https://prnt.sc/AnX8aCHeEgAz

Example of file name using function move / copy parts (6)
10122024-JSBL-Stmt-10122024-008-XXXX081720000721_001.pdf


*****
I just want to reverse the date format from DDMMYYYY to YYYYMMDD

Example - Final Result I want this
20241210-JSBL-Stmt-10122024-008-XXXX081720000721_001.pdf

Or is there any function that can pick date DDMMYYYY from the center of the name and prefix date in reverse YYYYMMDD order.

Please suggest.
mayakot98
 
Posts: 1
Joined: Mon Jul 21, 2025 7:55 am

Re: Prefix Date in Reverse order from Name

Postby Admin » Mon Jul 21, 2025 11:31 am

To achieve your goal of extracting the date in DDMMYYYY format from the filename and prefixing it in reversed format YYYYMMDD,
Bulk Rename Utility does not have a direct single-step function to reverse date parts automatically.
However, you can do this using a combination of features or by using the JavaScript Renaming engine for more flexibility.

Method 1: Using JavaScript Renaming (recommended for this task)

1. Open Bulk Rename Utility.
2. Go to the Special (14) section and select "Javascript Renaming".
3. Use a script to:
- Extract the date substring (DDMMYYYY) from the filename.
- Rearrange it to YYYYMMDD.
- Prefix the filename with the rearranged date.

Example JavaScript snippet (adapt as needed):

```javascript
// Extract date in DDMMYYYY format from filename (assumes fixed position)
var name = item.name; // filename without extension
var ext = item.ext; // extension

// Example: date is at position 9 to 16 (adjust indexes as needed)
var dateStr = name.substr(9, 8 ); // "10122024"

// Rearrange DDMMYYYY to YYYYMMDD
var dd = dateStr.substr(0, 2);
var mm = dateStr.substr(2, 2);
var yyyy = dateStr.substr(4, 4);
var newDate = yyyy + mm + dd;

// Create new name with prefix
item.name = newDate + "-" + name;
```

4. Preview the new names and run the rename.

Method 2: Manual steps using Move/Copy Parts and Auto Date (less flexible)

- Use Move/Copy Parts (6) to copy the date part (DDMMYYYY) to the front as you did.
- Then use the "Reformat Date" option in Name (2) to convert the date format from DDMMYYYY to YYYYMMDD.

However, "Reformat Date" expects a recognizable date separator format (e.g., 10-12-2024), so if your date is continuous digits (10122024), it may not work directly.

You can try:

- Use RegEx (1) to insert separators into the date part (e.g., insert dashes to get 10-12-2024).
- Then use Name (2) > Reformat Date with format `%d%m%Y>%Y%m%d` or similar.

But this is more complex and less straightforward than using JavaScript.

---

Summary:

- The easiest and most precise way is to use the JavaScript Renaming feature to extract and rearrange the date substring.
- Bulk Rename Utility's standard functions do not directly support reversing date parts inside filenames automatically.
Admin
Site Admin
 
Posts: 3047
Joined: Tue Mar 08, 2005 8:39 pm

Prefix date in names using a different date-format

Postby Luuk » Mon Jul 21, 2025 12:03 pm

With RegEx(1) having the "v2" checkmark, the "Match" and "Replace" can look like...
^(?!20\d{6}-)(.+-)(\d\d)(\d\d)(20\d\d)(-\d+-.+)
$4$3$2-$0

The red-part is to prevent renaming anything that was already prefixed.
Without any 'v2' checkmark, the "Replace" would be... \4\3\2-\1\2\3\4\5.

Remember, this reverses your DDMM formats, so make sure they have all been named with that format!
If I can think of easier ways, like admin is talking about, I will post them but much later today.
With me the regex is always easiest, but its just because Im using it all the time.
Luuk
 
Posts: 834
Joined: Fri Feb 21, 2020 10:58 pm


Return to BRU Support