(old post) Batch rename with regular expression [solved]

*** Please report new bugs here! ***

Moderators: xnview, Dreamer

User avatar
michel038
XnThusiast
Posts: 1505
Joined: Tue Sep 27, 2016 8:18 am
Location: France

(old post) Batch rename with regular expression [solved]

Post by michel038 »

I don't know if it's a bug or a suggestion ...

I'm trying to build a reg. exp in a sand box (regex101.com)
I want to add a word in filenames ... by replacing (year) by (year janvier)
regex01.png
This is working, the four digits of (year) are stored in $1


But XnViewMP does not process $1 in batch rename
regex02.png
Thanks
You do not have the required permissions to view the files attached to this post.
Last edited by michel038 on Wed Oct 29, 2025 9:24 pm, edited 3 times in total.
User avatar
xnview
Author of XnView
Posts: 47432
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Batch rename with regular expression

Post by xnview »

you can't use $1, please try
DCP
->
janvier DCP
Pierre.
User avatar
michel038
XnThusiast
Posts: 1505
Joined: Tue Sep 27, 2016 8:18 am
Location: France

Re: Batch rename with regular expression

Post by michel038 »

Yes, it's ok for this particular case ("DCP"),
I have already renamed files with similar methods, changing criterias in each case.

But it would be nice if full Regex was supported for other users in the future

Thanks
User avatar
michel038
XnThusiast
Posts: 1505
Joined: Tue Sep 27, 2016 8:18 am
Location: France

Re: Batch rename with regular expression

Post by michel038 »

Six years later, I found the answer in this post
Thanks to Jkm ...

Instead of using $1,$2,$3... we must use \1 , \2 , \3

In my example : replace ^([0-9]{4} by \1 janvier