Replace all after first 4 characters (digits)

Bulk Rename Utility How-To's

Replace all after first 4 characters (digits)

Postby Mightyracoon » Fri Aug 27, 2021 11:01 am

Any help appreciated in advance

Renaming a LOAD of files where the majority start with a unique 4-digit code (format 0000), followed by metadata jargon.

I'm looking to replace all of the jargon with "_ep_img" so the final format I'm looking for will be "0123_ep_img", minus quotation marks of course.

I've played around with the Remove (5) option; I attempted to use "Crop After 4", but that didn't seem to do the trick.

Anywhere obvious I'm going wrong with this? Happy to read on it :)
Mightyracoon
 
Posts: 2
Joined: Fri Aug 27, 2021 10:49 am

Re: Replace all after first 4 characters (digits)

Postby Luuk » Fri Aug 27, 2021 11:23 am

Remove(5) would need 'From'=='5' and 'To'=='999' to keep only the 1st-four characters, so then using Add(7) for a suffix.

But if all of your names dont start with 4-numbers, then instead I would use the RegEx(1) with a 'Match' and 'Replace' like...
^(\d{4}).+
\1_ep_img
Luuk
 
Posts: 692
Joined: Fri Feb 21, 2020 10:58 pm

Re: Replace all after first 4 characters (digits)

Postby Mightyracoon » Fri Aug 27, 2021 11:26 am

Luuk wrote:Remove(5) would need 'From'=='5' and 'To'=='999' to keep only the 1st-four characters, so then using Add(7) for a suffix.

But if all of your names dont start with 4-numbers, then instead I would use the RegEx(1) with a 'Match' and 'Replace' like...
^(\d{4}).+
\1_ep_img


Thank you so much!

The Remove/Add works now, I was missing the "To" entry like an idiot.

I'll have a look at the RegEx if I find that they're getting sloppy with putting the number at the front but so far, so good.

Thanks again mate!
Mightyracoon
 
Posts: 2
Joined: Fri Aug 27, 2021 10:49 am


Return to How-To


cron