Findstr: match filenames containing exactly a single dot

0

I am desparately trying to find all files within a folder and its subdirectories containing exactly a single dot. Reading the documentation of findstr I came up with this kind-of-regex, but it still matches all file names containing dots. In my understanding the regex I constructed should read: "Any characters except dots, then require a single dot, then again any characters except dots."

where /r directory *.* | findstr /irc:"[^\.]*\.[^\.]*"

I know I could install grep, but I want a solution that works out of the box.

Kapt.Brackbier

Posted 2015-10-27T22:02:20.097

Reputation: 13

Answers

0

Ok, I found the solution myself.

As [class]* matches zero or more occurences this expression matched whenever there was at least one (as opposed to exactly one) dot within a filename.

To make it match exactly one the position of the dot has to be specified. In my case I simply added the position specifiers "^" (beginning of a line) and "$" (end of a line), so that now the regex translates to "Lines with exactly a single dot anywhere between beginning and end of the line"

where /r directory *.* | findstr /irc:"^[^\.]*\.[^\.]*$"

Kapt.Brackbier

Posted 2015-10-27T22:02:20.097

Reputation: 13