1.

Solve : Find Next?

Answer»

Hello,

I would like look for  string in all the files on my computer. So I came up with the FOLLOWING sequence or order of how the batch should work but I don't know how to write the code.

find FIRST file
set "path\name of the file" as variable
look for string
go on with the next file

Also if possible I would like to exclude all the files with the extension *.TMP

Thanks

Almn

do this : findstr /?

Yes I have tried that but it seems that its only  to look for the screen . I just would like the command line that sets the first file in the computer as a vairable,for example "file".

Thanks Anyways

AlmnSorry, al968. It is impossible to figure out what you want to accomplish.

find first file
set "path\name of the file" as variable
look for string
go on with the next file

What do you mean "as variable". As what variable? Should variable names be generated?

"find first file" Do you mean find the first file that contains the string or the first file on your HARD drive.

Never mind how to solve the problem. Let us know what you want as an end result when the search is complete.

======Example

I would like a BAT file that will produce a text file containing the path/filename of all files on my computer containing a given string.

If I run MyBAT "apple banana" myfile.txt

Then at the end of the run, myfile.txt will contain
c:\abc\def.doc
c:\ghi\jkl\mno.txt
....

where those files contain the exact text "apple banana"

=========

Is that what you want, or what?

Mac
First of All thank You for your answer  
By first file I mean First file on the hard drive.
What I would like to do is for every file on the computer to be set as a variable then to check if the string is present in that file, and if it is echo the neame of the file otherwise repeat the first steps with the next file.

Thanks

Almn
Quote

Yes I have tried that but it seems that its only  to look for the screen . I just would like the command line that sets the first file in the computer as a vairable,for example "file".

Thanks Anyways

Almn
you can follow the examples here http://www.ss64.com/nt/findstr.htmlHere is a simple solution for a case insensitive search from the current directory that does not SKIP the .tmp files:
Code: [Select]echo off
set /p string=Please enter string to search:
findstr /s /m /i /c:"%string%" * 2>NUL
If you want to skip .tmp files, you COULD use a FOR loop with /R.  This should be enough to get started.


Discussion

No Comment Found