I'm using the following rename script for e.g. this example filename:
Konto_0320435115-Auszug_2022_0008.PDF
function OnGetNewName(getNewNameData)
{
var name = getNewNameData.newname_stem_m;
var ext = getNewNameData.newname_ext_m;
//replace underscores with space
//move date from last position to first and remove parts
name = name.replace( /_/g ," " )
.replace(/(.*)( vom| zum| per) (\d{2}) (\d{2}) (\d{4})/,'$5-$4-$3 $1')
.replace(/(Konto) (\d.*)-(Auszug) (\d{4}) (\d{3,4})/,'$4 $1$3 $2 #$5')
.replace(/ae/g,"ä")
.replace(/Ae/g,"Ä")
.replace(/oe/g,"ö")
.replace(/Oe/g,"Ö")
.replace(/ue/g,"ü")
.replace(/Ue/g,"Ü")
.replace(/Michäl/g,"Michael")
;
// name = name.replace(/(.*)( vom| zum) (\d{2}) (\d{2}) (\d{4})/,'$5-$4-$3 $1');
return name + ext;
}
Which gives this result after applying:
2022 KontoAuszug 0380445445 #0008.PDF
Is there any chance to get "Auszug" into lower case so the complete word reads "Kontoauszug", with the above script?
Of course I could split this rename line .replace(/(Konto) (\d.*)-(Auszug) (\d{4}) (\d{3,4})/,'$4 $1$3 $2 #$5')
into different parts to achieve this, but would like to have this in one line.
Did not test, you might have to put ${1}auszug.
EDIT : Tested, no need for extra bracket, first suggestion should give you what you expect.
EDIT2 : Same thing goes for the Konto part which is exactly matched, so you could even replace by :
Yes, sure I can put the desired, final part of the filename into the rename command
However, I would like to use the regex groups without using a static name, "Kontoauszug" in this case.
Since you are exactly matching these parts of the filename, capture groups are useless. Capture groups are interesting when you don't know exactly what you're matching (e.g. the \d.* or \d{3,4} ...).