Page 1 of 1

How can I add a 4 to the end.....

PostPosted: Sun Sep 04, 2022 6:18 am
by Ronstang
...of any file or folder that has a date in it with the format (XXXX)?

I would like:

Dudes (1987) TCMUND

To simply be changed to:

Dudes (1987) TCMUND4

I have thousands of files and folders I need to do this to so I know what codec I used to encode them.

Thanks

Append 4 to names with (yyyy)

PostPosted: Sun Sep 04, 2022 3:13 pm
by Luuk
Greetings Ronstang, with RegEx(1) the "Match" and "Replace" can look like...
(.*\((19|20)\d\d\).*)(?<!4)$
\14

This can append "4" to names with (19yy) or (20yy) unless the name does already have "4" at the end?
The red-parts is called a negative look-behind, and he is saying which names should not be matched.
So if needing more exceptions, like any names ending with a digit, could instead use... (?<!\d)

Re: How can I add a 4 to the end.....

PostPosted: Mon Sep 05, 2022 8:48 pm
by Ronstang
Thank you so much Luuk that worked....but I found a problem I had not considered.

I only want it to change the file name of files with extensions .ts, .mkv, .nfo, and .srt.....but there is a problem with most of my .SRT files....they have language identifiers in them so the file

1941 (1979) SONY.eng.srt would need to become:

1941 (1979) SONY4.eng.srt but currently it becomes:

1941 (1979) SONY.eng4.srt

Is there a way to compensate for these stipulations?

Thanks

Append 4 to some names with (yyyy)

PostPosted: Tue Sep 06, 2022 12:31 am
by Luuk
To conduct only those file-extensions, must first put a checkmark inside for "Inc.Ext.", so then editing the "Match" and "Replace" like...
(.*\((19|20)\d\d\).*?)(?<!4)(\.(eng|spa|rus))?(?<!4\.(eng|spa|rus))\.(ts|mkv|nfo|srt)$
\14\3

This to make sure that "4" always goes in front of any language identifiers like .eng, .spa, or .rus at the end.
The look-arounds are still both saying not to conduct any names, if they do already have the "4" being suffixed.
You might want to change both 4 --> \d, in case later preferring to suffix them like digits-4 instead of digits4 ?

Re: How can I add a 4 to the end.....

PostPosted: Tue Sep 06, 2022 9:26 am
by Admin
Luuk is the absolute master of RegEx 8) 8) 8) fantastic, thank you for helping so many :!:

Re: How can I add a 4 to the end.....

PostPosted: Fri Sep 09, 2022 3:20 am
by Ronstang
Luuk is the absolute master of RegEx 8) 8) 8) fantastic, thank you for helping so many :!:


Most definitely, he is a true master and amazingly generous with his knowledge and I want him to know he is truly appreciated!

Been busy but finally had time to revisit this and test your latest suggestion Luuk and of course it worked like a charm.

This program has made my life so much easier in managing my emby server and my HUGE collection of media. I constantly learn and thus am making constant changes.....so of course I learn that the way I used to do things needs to be updated and this program help me make small changes to a large number of files and folders quickly to make my emby experience better every day.

I have no understanding of the language used to make this program work correctly, I have a feeling it is script language, but any way it is Greek to me as I know almost nothing about coding. I have gleaned a LITTLE understanding and sometimes I can make small changes to update my current settings....but without Luuk I may not have any of the presets I currently use. He is always the first to answer my posts and help me and always there to fine tune what I want to do until it is working correctly. I knew when I posted this that I would wake up in the morning to a pleasant post from Luuk with a solution to my needs....and he was.

Thank you so much for your generosity with your time and knowledge and your pleasant eagerness to always help Luuk....if there were more people like you in the world it would be a much better place.