lowtechsun
lowtechsun

Reputation: 1955

Find text string or part of text with dot in grepWin

I am using grepWin on Windows 7 64. http://tools.tortoisesvn.net/grepWin.html

I have a folder with files and their duplicate copies.

The original files are named "FILENAME DOT FILETYPE" (without spaces), for example "cartonbox.shelf".

The copies of these file are named "FILENAME DOT 1 DOT FILETYPE" (without spaces), for example "cartonbox.1.shelf".

I am trying to find all files that contain the exact string:

"DOT 1 DOT FILETYPE" (without spaces), so all files that have for example ".1.shelf" in them.

How can I do that in grepWin please?

If I try "\.1\shelf" or "\.1\.shelf" for example I do not get any results.

What is my mistake please? Been reading http://www.regular-expressions.info/ but cannot come up with correct pattern.

How can I generally search for an exact part of the filename regardless of symbols?

Basically if the file I want to find has for example "garden_1.1.4-JE50.tree" in it how do I tell grepWin to find this exact string of text including underscore, dots or other characters?

Upvotes: 2

Views: 21025

Answers (1)

AbsoluteƵERØ
AbsoluteƵERØ

Reputation: 7880

Grep stands for g/re/p (global / regular expression / print)

It searches IN files, not file names. That text would need to be text-readable in the file for which you are searching.

In the directory you want to search, you could do something like:

dir *.* /b/s > my_file.txt

Then you can perform your regular expressions checks with grepWin on my_file.txt

In Unix and Linux you normally pipe the commands via the command line:

ls -a | grep \.1\.shelf$

In Windows you would use

dir * /b | findstr \.1\.shelf$

Update 2023

You can now install the Windows Subsystem for Linux as well as GNU Grep.

dir * /b | grep \.1\.shelf$

Or in WSL you would use find in the directory you're searching:

find . -iregex "\.1\.shelf$"

Upvotes: 8

Related Questions