Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Find Next  (Read 2718 times)

0 Members and 1 Guest are viewing this topic.

almn

  • Guest
Find Next
« on: October 07, 2006, 06:54:08 PM »
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

« Last Edit: October 07, 2006, 06:54:31 PM by almn »

ghostdog74



    Specialist

    Thanked: 27
    Re: Find Next
    « Reply #1 on: October 07, 2006, 09:12:58 PM »
    do this : findstr /?


    almn

    • Guest
    Re: Find Next
    « Reply #2 on: October 08, 2006, 06:03:00 AM »
    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

    QBasicMac

    • Guest
    Re: Find Next
    « Reply #3 on: October 08, 2006, 06:58:00 AM »
    Sorry, 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

    almn

    • Guest
    Re: Find Next
    « Reply #4 on: October 08, 2006, 07:26:52 AM »
    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

    ghostdog74



      Specialist

      Thanked: 27
      Re: Find Next
      « Reply #5 on: October 08, 2006, 08:50:15 AM »
      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.html

      GuruGary



        Adviser
        Re: Find Next
        « Reply #6 on: October 10, 2006, 11:02:00 PM »
        Here 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.