Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hey guys.
I'm having a problem with the FIND command.
Say I want to find the string "2000" in a file of numbers, how can I just locate this number rather than also locating "20000" "200000" etc...
Any help would be fantastic.

Better you try
Type FileName | Find /V "20000" | Find /V "200000" | Find /V "2000000" | Find "2000"
The above script will exclude the strings 20000, 200000, 2000000. If this doesn't suffice post again

Do you want to find 2000 only if it's a whole number and not part of a larger number? If you want to find lines like this:
2000
652000
200098but not
5620000
2000000then this is the best method
find "2000" file.txt | find /V "20000"

Hi.
Thanks for the suggestions. I'm not sure if I was being clear enough so here goes: I have a number of word files all containing unique numbers. I require a way of identifying which word file a specific number is in. I have a batch file where the user enters any number to search for:
find /i /c "%1" "c:\path\path\path\*.doc"
so say a user enters a five digit number, this number may also feature within a six digit number. This would give me more than one file the number could be in. Is there a way around this problem? I.E. if I wanted to find the word file containing number 321, this number would also be found in any files with numbers such as 503216, 3210 and so on.

This will do it accurately:
FINDSTR "^%1[^0-9] [^0-9]%1[^0-9] ^%1$ [^0-9]%1$" "c:\path\path\path\*.doc"
That will only match the string on %1 if it is surrounded by non-numeric characters (or by line breaks).
The external command FINDSTR is only avaliable by default on NT systems.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br___________________________________________________________________________________

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |