#1 2025-07-25 11:47

reframer
Member
Registered: 2025-07-25
Posts: 3

Adjust name and take parts from the existing name

Hi all,

I have a filename:
The_Test_Article_No_31_from_22._July_2025

This academic article comes every week or month, so I want:

The Test - 2025-07-22


The easy way would be:
- Insert: The Test - 2025-

And now the rest:
- Find January in the name and replace it with 01
- Or find February in the name and replace it with 02
- And so on

And
- Find any 2 digit number and dot
- Replace it with only the 2 digit numer / delete the dot
- So from 22. to 22


Happy to get some help.

Offline

#2 2025-07-25 17:50

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,492

Re: Adjust name and take parts from the existing name

This can achieved using the following rules:

1) Clean Up: Replace with spaces "." "_", Normalize spaces, Fix spaces (skip extension)
2) Regular Expressions: Replace expression "\s+Article No\s+\d+\s+from\s+" with " - " (skip extension)
3) Reformat Date: Convert to "yyyy-mm-dd" from "d mmmm yyyy", whole words only, skip extension

Input:
The_Test_Article_No_31_from_22._July_2025.pdf

Output:
The Test - 2025-07-22.pdf

Offline

#3 2025-07-27 08:22

reframer
Member
Registered: 2025-07-25
Posts: 3

Re: Adjust name and take parts from the existing name

Wow, first of all thank you very much for the quick support.

Second, I learned a lot here, again. I think my biggest weak point is the regular expression. Since I don't know its power and many options, I try to create solutions without using regular e.
I tried many times a "how to learn regular expressions" wiki but without success.

Third, I did not know that the function date with mmmm is a written format of a month.

Finally, a new question here:
Imagine the example from above:
The_Test_Article_No_31_from_22._July_2025.pdf

However, it can also be like:
The_Test_SpecialArticle_No_31_from_22._July_2025.pdf

Or
The_Test_LongMagazin_from_22._July_2025.pdf

And so on. And the output should always be like:
The Test - 2025-07-22.pdf

In your solution from above:
2) Regular Expressions: Replace expression "\s+Article No\s+\d+\s+from\s+" with " - " (skip extension)
The "Article No" is explicitly mentioned.

But is there a logic to say "any word other than The_Test should be deleted"?

Offline

#4 2025-07-27 11:19

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,492

Re: Adjust name and take parts from the existing name

Since we don't know what the variable part can be (e.g. "Article_No_31", "SpecialArticle_No_31", "LongMagazin") then you have to find a common delimiter, which appears to be "from" followed by a number.

In this case you can delete everything from the start up to "from" using the Delete rule, or delete everything from the start up to "from" followed by a number using the Regular Expression rule, for extra validation.

Regular Expressions rule: Replace expression "\A.*?\s+from\s+(?=\d+)" with "The Test - " (skip extension)

Input:
The_Test_Article_No_31_from_22._July_2025.pdf
The_Test_SpecialArticle_No_31_from_22._July_2025.pdf
The_Test_LongMagazin_from_22._July_2025.pdf

Output:
The Test - 2025-07-22.pdf
The Test - 2025-07-22.pdf
The Test - 2025-07-22.pdf

Offline

#5 Yesterday 11:11

reframer
Member
Registered: 2025-07-25
Posts: 3

Re: Adjust name and take parts from the existing name

Dear Admin, thank you again for the quick support.

I try to understand and learn this logic. I got the way of "common delimiter".

But here comes the - I think - final challenge for you: Without having a common delimiter.

Input:
The_Test_Article_No_31_from_22._July_2025.pdf
The_Test_SpecialArticle_No_31_from_22._July_2025.pdf
The_Test_LongMagazin_from_22._July_2025.pdf
The_Test22.July2025.pdf
The_Test22July2025.pdf
The_Test_22._July_2025.pdf
The_Test_22_July_2025.pdf
The_Test_22_07_2025.pdf
TheTest22725.pdf

Wished output:
The Test - 2025-07-22.pdf

Here I could again do not find a solution for that.

Offline

Board footer

Powered by FluxBB