Page 1 of 1
help on regexp rename
Posted: 22 Apr 2015 09:47
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
Re: help on regexp rename
Posted: 22 Apr 2015 09:57
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?
Re: help on regexp rename
Posted: 22 Apr 2015 10:18
by yusef88
highend wrote:
From the end of the name?
So why do you remove chars from the beginning then?
sorry for mistake it meant to be keeping characters form the end and yes i want the output like that
Re: help on regexp rename
Posted: 22 Apr 2015 10:55
by highend
It isn't necessary to take ar / en into account, the match for the series+episodes is relevant.
Re: help on regexp rename
Posted: 22 Apr 2015 11:52
by yusef88
smart method to handle episodes renaming

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
Re: help on regexp rename
Posted: 22 Apr 2015 12:18
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".
Re: help on regexp rename
Posted: 22 Apr 2015 14:30
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]
Re: help on regexp rename
Posted: 22 Apr 2015 15:37
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
Re: help on regexp rename
Posted: 22 Apr 2015 16:23
by yusef88
really impressive thanks a lot highend
Re: help on regexp rename
Posted: 02 Jun 2015 16:35
by yusef88
can this pattern used in find files?
Re: help on regexp rename
Posted: 02 Jun 2015 17:47
by highend
Why not? Same regex engine...
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...