Regex: Return Videos That Do Not Contain Year of Release
-
- Posts: 3
- Joined: Fri Mar 23, 2018 9:00 pm
Regex: Return Videos That Do Not Contain Year of Release
I am trying to locate all video files which do not contain a year surrounded by parentheses. For example, of the following 2 files I only want to see 'MyMovie1967.mkv' in the results. I will then add the parentheses myself.
MyMovie1967.mkv
MyMovie (1967).avi
I thought that this search might do what I need, but this also returns files with the year in parentheses.
(^.+)((\([012345679]{4}\)){0})
Any help would be greatly appreciated.
MyMovie1967.mkv
MyMovie (1967).avi
I thought that this search might do what I need, but this also returns files with the year in parentheses.
(^.+)((\([012345679]{4}\)){0})
Any help would be greatly appreciated.
Re: Regex: Return Videos That Do Not Contain Year of Release
Does this work or you?:
It wil report all files containing 4 numbers (starting with 1 or 2, because 1967 or 2018) without surrounding ()
Code: Select all
regex:^.*[^\(][12][0-9]{3}[^\(].*
Re: Regex: Return Videos That Do Not Contain Year of Release
I should have tested that before posting. Here is a slightly better version:
This will exclude larger numbers, too.
Code: Select all
regex:^.*[^(0-9)\(][12][0-9]{3}[^(0-9)\)].*
-
- Posts: 3
- Joined: Fri Mar 23, 2018 9:00 pm
Re: Regex: Return Videos That Do Not Contain Year of Release
That expression returns what I believe is the list of files I need!
I did notice however that it also returns the following file:
I am curious as to why this file is included when for example the following file is not included:
Is this what your expression equates to?
Get filenames that:
(1) begins with any character one or more times
(2) NOT followed by a digit OR an opening parenthesis
(3) followed by 1 OR 2
(4) followed by three digits
(5) NOT followed by a digit OR a closing parenthesis
(6) followed by any character one or more times.
I did notice however that it also returns the following file:
I am curious as to why this file is included when for example the following file is not included:
Is this what your expression equates to?
Get filenames that:
(1) begins with any character one or more times
(2) NOT followed by a digit OR an opening parenthesis
(3) followed by 1 OR 2
(4) followed by three digits
(5) NOT followed by a digit OR a closing parenthesis
(6) followed by any character one or more times.
Re: Regex: Return Videos That Do Not Contain Year of Release
Files that don't have 4 digits enclosed in parens.
That way it can include your movies from the 1700's too .
Code: Select all
!regex:\(\d\d\d\d\)
Re: Regex: Return Videos That Do Not Contain Year of Release
Because it's name also includes a 4 digit number that *isn't* enclosed by (): 2049NeonLadder wrote:That expression returns what I believe is the list of files I need!
I am curious as to why this file is included
The match is for 4 digits that aren't surrounded by other digits or ()
Re: Regex: Return Videos That Do Not Contain Year of Release
That would also match "Hello World.txt", I think.therube wrote:Files that don't have 4 digits enclosed in parens.
That way it can include your movies from the 1700's too .Code: Select all
!regex:\(\d\d\d\d\)
Hahaha, movies from the 1700's Starring the great-great-grandparents of the Lumiere brothers
Re: Regex: Return Videos That Do Not Contain Year of Release
NotNull, try this, literals will work:NotNull wrote:Code: Select all
regex:^.*[^(0-9)\(][12][0-9]{3}[^(0-9)\)].*
Code: Select all
regex:[()]
Do you know Regex flavor needs "\" ?
-
- Posts: 3
- Joined: Fri Mar 23, 2018 9:00 pm
Re: Regex: Return Videos That Do Not Contain Year of Release
Thanks NotNull and therube. I have exactly what I need, and it is greatly speeding up the process of cleaning up my library!
Re: Regex: Return Videos That Do Not Contain Year of Release
Hey, that works too! I had no idea .. Nice catch!Stamimail wrote:NotNull, try this, literals will work:NotNull wrote:Code: Select all
regex:^.*[^(0-9)\(][12][0-9]{3}[^(0-9)\)].*
I'm just learning now some Regex, and I didn't understand why you tried to escape by "\"Code: Select all
regex:[()]
Do you know Regex flavor needs "\" ?
I was escaping the (), because parentheses are also used for grouping - like gr(a|e)y in the Everything documentation - but that seems unneeded.Don't know if other Regex flavors need the escaping.
BTW: Everything uses the Perl regular expression language.
Re: Regex: Return Videos That Do Not Contain Year of Release
inside character class [] only some characters need to be escaped:
From http://www.regular-expressions.info/charclass.htmlwww.regular-expressions.info
"In most regex flavors, the only special characters or metacharacters inside a character class are the closing bracket ], the backslash \, the caret ^, and the hyphen -. The usual metacharacters are normal characters inside a character class, and do not need to be escaped by a backslash. To search for a star or plus, use [+*]. Your regex will work fine if you escape the regular metacharacters inside a character class, but doing so significantly reduces readability.
In most regex flavors, the only special characters or metacharacters inside a character class are the closing bracket ], the backslash \, the caret ^, and the hyphen -. The usual metacharacters are normal characters inside a character class, and do not need to be escaped by a backslash. To search for a star or plus, use [+*]. Your regex will work fine if you escape the regular metacharacters inside a character class, but doing so significantly reduces readability.
To include a backslash as a character without any special meaning inside a character class, you have to escape it with another backslash. [\\x] matches a backslash or an x. The closing bracket ], the caret ^ and the hyphen - can be included by escaping them with a backslash, or by placing them in a position where they do not take on their special meaning. The POSIX and GNU flavors are an exception. They treat backslashes in character classes as literal characters. So with these flavors, you can't escape anything in character classes.
Re: Regex: Return Videos That Do Not Contain Year of Release
Useful info. Thanks, ovg!