Move file name portions in variable file name length

Advanced Renamer forum
#1 : 26/01-25 10:45
Sunny
Posts: 3
Hi all,

I'm aware that my question already might have been adressed in the forum,
but I did not find the correct key words for my problem.
So I ask the forum now. Pls take my apologises for this.

I'm actually facing the problem that I receive files with multiple useful information (date information yyyymmdd (8 digit) and counter ccc (9 digit) but with variable name length. In particular the file names look like this:

variabletextlength_yyyymmdd_ccccccccc.pdf
or
variabletextlength_yyyymmdd.pdf

I would like to rename to

yyyymmdd_variabletextlength_yyyymmdd_ccccccccc.pdf
or
yyyymmdd_variabletextlength.pdf

Which syntax, or features shall I use ???
Thanks for the help
#2 : 26/01-25 12:15
Styb
Posts: 145
Reply to #1:
Hi,
You can look at the filename as being made up of different portions separated by the underscore character. This way it's possible to use the numbering of these parts when using the regular expressions.
Add the Replace method:
Replace: (.*)_(.*)_(.*)
Replace with: \2_\1_\2_\3
Enable the option: Use regular expressions
Apply to:Name
See the image below for the first example:
https://i.postimg.cc/V6tWQ0m2/img43.png

Regards from Italy :)

#3 : 26/01-25 15:05
Miguel
Posts: 171
Reply to #1:
Hi Sunni,

I'm not sure if there is a single method to achieve what you're looking for. However, I’ve managed to accomplish it using two separate Replace methods.

Method 1:

Replace: (\w.*)_(\d{8})_(\d{9})
Replace with: \2_\1_\2_\3
Use regular expression

Method 2:

Replace: (\w.*)_(\d{8})$
Replace with: \2_\1
Use regular expression

EDIT: The next is not necessary
----------------------------
For Method 2, press the small {if} button next to "Name" and configure it as follows:
Apply condition: Checked.
Field: Name.
Regular expression: Selected.
Pattern: (\w.*)_(\d{8})$
---------------------------------
In both methods apply to Name.

Screenshots:
https://drive.google.com/file/d/14Y4BxFl-Nqby7Ku -H0jh7ONDcQ0cWFx4/view?usp=drive_link


Miguel.

EDIT: I´m using version 4.08


edited: 26/01-25 18:52
#4 : 27/01-25 15:12
Sunny
Posts: 3
Reply to #2:

Hi Styb

Thank you for the help.
This works,
which, to be honest, suprises me, since the variable_text_length is also using multiple underscores.

If one compares this solution to the one from Miguel one would not expect such a good result.
I think I need to properly understand the syntax ;-)

Sunny

edited: 27/01-25 15:16
#5 : 27/01-25 15:15
Sunny
Posts: 3
Reply to #3:

Hi Miguel

Thank you for the help.
This works very good.
I think I need to properly understand the syntax and then can do these kind of batches by myself lateron ;-)

Or just ask people who know :-)

Sunny

PS
One is not lost, as long as one knows another one, who knows someone, who knows :-))