help on regexp rename

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

help on regexp rename

Post by yusef88 »

i need remove characters form the end of name,provided that removing begins after .ar or .en

Code: Select all

the.subtitle.S03E04.ar.srt
the.subtitle.S03E04.en.srt
the next code working only after .ar

Code: Select all

^(.*)(.{5})(\|.en|.ar..[^.]+)$|^([^.]*)([^.]{4})$ > $2$3$5
To see the attached files, you need to log into the forum.

highend
Posts: 14953
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: help on regexp rename

Post by highend »

i need remove characters form the end of name
From the end of the name?

So why do you remove chars from the beginning then?

Just give me an example of how the output for your two examples should look like and I'll give you the answer :)

Code: Select all

the.subtitle.S03E04.ar.srt
the.subtitle.S03E04.en.srt
Output?

Code: Select all

S03E04.ar.srt
S03E04.en.srt
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: help on regexp rename

Post by yusef88 »

highend wrote: From the end of the name?
So why do you remove chars from the beginning then?
:o
sorry for mistake it meant to be keeping characters form the end and yes i want the output like that

Code: Select all

S03E04.ar.srt
S03E04.en.srt

highend
Posts: 14953
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: help on regexp rename

Post by highend »

Code: Select all

^(.*?)([ES0-9]{6}.*)$ > $2
It isn't necessary to take ar / en into account, the match for the series+episodes is relevant.
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: help on regexp rename

Post by yusef88 »

smart method to handle episodes renaming :tup: but not all series have this sequence in the name ٍ"S00e00" sometimes it maybe 1×1
so I have 2 scripts the first keeps characters form the beginning and the 2nd keeps them from the end.

see i can keep characters from name beginning without affecting subtitle Lang (ar or en)

Code: Select all

^(.{18})(.*(?=.en|.ar.))(.+) > $1$3
possible to apply above method to keep characters form end?
if not ,could you please make your scripts keep the letters before "S00e00" to be like that "Bates.Motel.S03E04" and thanks
To see the attached files, you need to log into the forum.

highend
Posts: 14953
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: help on regexp rename

Post by highend »

English isn't my main language and it's hard for me to grasp what you want exactly.
sometimes it maybe 1×1
What does that even mean?

Why don't you post all that different episode names (different = some use a subtile language identifier, some have the full "sxxexx" pattern, some the "1x1"?) and at same time post what a regexreplace should leave as the final name for each of them.

Patterns that use (){xx} to gather a specific number of characters are (mostly) too limited to be used on a wider base of source patterns.

The best way to handle all names would be a script that looks into the name, checks if there is a common pattern (like the exxsxx or a ".ar.|.en." etc.) and chooses the best regexreplace automatically. No "keep characters at the beginning or at the end".
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: help on regexp rename

Post by yusef88 »

my poor english prevents me clarifying my point in an optimal way so -as you suggested - I'll put an example

Code: Select all

Bates Motel 02×10.720p.HDTV.2CH.x265.HEVC-PSA.mp4
Bates Motel 02×10.720p.HDTV.2CH.x265.HEVC-PSA.ar.srt
Bates Motel 02×10.720p.HDTV.2CH.x265.HEVC-PSA.en.srt
↓↓↓

Code: Select all

Bates Motel 02×10.mp4
Bates Motel 02×10.ar.srt
Bates Motel 02×10.en.srt
keep [Bates Motel] [×0-9]

highend
Posts: 14953
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: help on regexp rename

Post by highend »

Edit: Shortened the regex a bit more...

Code: Select all

^(.*?)([ES0-9]{6}|[0-9]+(?:x|\xD7)[0-9]+)(.*?)((?:\.ar|\.en)?\.[^.]+)$ > $1$2$4
(?:x|\xD7)
Your examples use an unicode char "×" (and not the latin "x"), hence this expression.

Turns:

Code: Select all

Bates Motel 2×1.720p.HDTV.2CH.x265.HEVC-PSA.mp4
Bates Motel 2x0.720p.HDTV.2CH.x265.HEVC-PSA.en.srt
Bates Motel 02×10.720p.HDTV.2CH.x265.HEVC-PSA.mp4
Bates Motel 02×10.720p.HDTV.2CH.x265.HEVC-PSA.ar.srt
Bates Motel 02x10.720p.HDTV.2CH.x265.HEVC-PSA.en.srt
Bates Motel S02E10.720p.HDTV.2CH.x265.HEVC-PSA.mp4
Bates Motel S02E10.720p.HDTV.2CH.x265.HEVC-PSA.ar.srt
Bates Motel S02E10.720p.HDTV.2CH.x265.HEVC-PSA.en.srt
into:

Code: Select all

Bates Motel 2×1.mp4
Bates Motel 2x0.en.srt
Bates Motel 02×10.mp4
Bates Motel 02×10.ar.srt
Bates Motel 02x10.en.srt
Bates Motel S02E10.mp4
Bates Motel S02E10.ar.srt
Bates Motel S02E10.en.srt
One of my scripts helped you out? Please donate via Paypal

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: help on regexp rename

Post by yusef88 »

really impressive thanks a lot highend
To see the attached files, you need to log into the forum.

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

Re: help on regexp rename

Post by yusef88 »

Code: Select all

[ES0-9]  (?:x|\xD7)
can this pattern used in find files?

highend
Posts: 14953
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: help on regexp rename

Post by highend »

Why not? Same regex engine...

Code: Select all

(?:x|\xD7)
This doesn't make much sense in a search, this pattern was used for a search + replace because (?:...) means: don't capture it into a backreference...
One of my scripts helped you out? Please donate via Paypal

Post Reply