How to add a hyphen between 3 capital letters

Bulk Rename Utility How-To's

How to add a hyphen between 3 capital letters

Postby Ronstang » Tue Nov 15, 2022 9:44 pm

I have a bunch of files named similar to the following.

Attack of the Puppet People (1958) TCMFPAMF.eng.srt
Attack of the Puppet People (1958) TCMFPAMF.mkv

And to make it easier to identify with a quick visual I would like them to be renamed:

Attack of the Puppet People (1958) TCMFPAM-F.eng.srt
Attack of the Puppet People (1958) TCMFPAM-F.mkv

Now the given here is I only want to add the hyphen if the last capital letter is an "F" but the capital letter that precedes it is not always the same.

Is this possible?

Thanks
Ronstang
 
Posts: 45
Joined: Tue Feb 09, 2021 2:14 am

Re: How to add a hyphen between 3 capital letters

Postby Ronstang » Tue Nov 15, 2022 9:52 pm

I'm an idiot, typed a 3 instead of a 2 in the title but there is no option to edit.....
Ronstang
 
Posts: 45
Joined: Tue Feb 09, 2021 2:14 am

Insert a hyphen between last 2 capital letters

Postby Luuk » Wed Nov 16, 2022 1:18 am

Greetings Ronstang, with RegEx(1) the "Match" and "Replace" can be like...
(.+[A-Z])(F)$
\1-\2
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm

Re: How to add a hyphen between 3 capital letters

Postby Ronstang » Wed Nov 16, 2022 6:25 am

Thanks so much Luuk, that works except on my subtitle files that have a language identifier in the file name like the following:

Attack of the Puppet People (1958) TCMFPAMF.eng.srt

It does nothing to files like this.

Thanks
Ronstang
 
Posts: 45
Joined: Tue Feb 09, 2021 2:14 am

Insert hyphen between a capital letter and F

Postby Luuk » Wed Nov 16, 2022 5:13 pm

Many apologies Ronstang, for language identifiers like eng, spa, fra, can change the "Match" to...
(.+[A-Z])(F|F\.(eng|spa|fra))$

If the language identifiers is always 3-lowercase english letters, can change the "Match" to...
(.+[A-Z])(F|F\.[a-z]{3})$

If ' (year) ' must be in front of the capital letters, can use something like...
(.+ \(\d{4}\) [A-Z]+)(F|F\.[a-z]{3})$
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm

Re: How to add a hyphen between 3 capital letters

Postby Ronstang » Sat Nov 26, 2022 3:55 am

Thanks again Luuk....you are always here to save the day. It feels like I am coming to this forum to ask you a question as you are always the first to answer. You are a great asset to this community.

Quick question.....how can I tweak what you have provided in this thread to add a -F or other hyphen and letter to files that don't already have them? They will always be named like the files in the first thread. While the actual letters change there is always a string of capital letters at the end of all files.

Thanks
Ronstang
 
Posts: 45
Joined: Tue Feb 09, 2021 2:14 am


Return to How-To