Page 1 of 1

Replace specific digit in each filename?

PostPosted: Wed May 12, 2021 9:35 pm
by lordpontiff
I was wondering how I should go about this.

Specifically, I want to change the underlined character in each file from a 2 to an 8.

7AB50E44-1ABE787D-5E53A204-C0

I can't just use basic match and replace or translation as many of the files have multiple '2's in them which need to remain unchanged.. But all of the files have the same amount of characters in them.

Thanks...

Re: Replace specific digit in each filename?

PostPosted: Wed May 12, 2021 10:34 pm
by Luuk
If the 24th-character is always 2, then settings like...
Remove(5) with From=24 and To=24
Add(7) with Insert=8 and At=24
Filters(12) with Name Min/Max=33 (for 3-character extensions)

If the 24th-character is sometimes 2, then RegEx(1) with a Match and Replace like...
^(.{23})2(.{5})$
\18\2

Re: Replace specific digit in each filename?

PostPosted: Sat May 15, 2021 8:50 pm
by lordpontiff
Awesome, thank you.

Re: Replace specific digit in each filename?

PostPosted: Wed Sep 20, 2023 1:40 am
by lordpontiff
Luuk wrote:If the 24th-character is always 2, then settings like...
Remove(5) with From=24 and To=24
Add(7) with Insert=8 and At=24
Filters(12) with Name Min/Max=33 (for 3-character extensions)

If the 24th-character is sometimes 2, then RegEx(1) with a Match and Replace like...
^(.{23})2(.{5})$
\18\2


Necrobumping here, but hoping for some help.

For the regex example, how would I switch it to replace a 7 with an 8, instead of replacing 2 with 8? I tried changing the underlined 2 to 7, but that broke it, and I'm not sure why or how it works exactly.

I need to use the regex because sometimes the 24th digit isn't 2, and in that case I need it to not be renamed...

Thanks, hopefully someone sees this.

In 29-char names, if 24th-char is 7, replace it with 8

PostPosted: Wed Sep 20, 2023 3:50 am
by Luuk
Its just a bad copy/paste, but this might make it easier to read and edit...
^(.{23})[7](.{5})$
\18\2

^ ======= The very beginning.
(.{23}) === 23 characters (grouped) for using \1 in the replace.
[7] ====== One 7... You might prefer [27] to say one 2 or 7.
(.{5}) ==== 5 characters (grouped) for using \2 in the replace.
$ ======= The very end, so only 29-character names can be edited.