Batch File or C++?
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Batch File or C++?

  1. #1
    Senior Member Info Tech Geek's Avatar
    Join Date
    Jan 2003
    Location
    Vernon, CT
    Posts
    828

    Batch File or C++?

    I would like to make a small script or program to run a search on a network share and save all hits to a file. Or even open up MS Find fill in the blanks and leave the results up.


    I'm searching \\System123\File321
    For "XzY"
    then "ZyX"
    and then XyZ"

    Then onto \\System234\File321
    For "XzY"
    then "ZyX"
    and then XyZ"

    Any hints or tips on how I should go about this?

    (this is for text within the file, not by file name)

  2. #2
    Senior Member tampabay420's Avatar
    Join Date
    Aug 2002
    Posts
    953
    Code:
    dir *.exe /s >> dir.txt
    this should scan all folders and subsets for *.exe and Append them to dir.txt
    this is just one way too do it...
    yeah, I\'m gonna need that by friday...

  3. #3
    Deceased x acidreign x's Avatar
    Join Date
    Jul 2002
    Posts
    455
    I agree, a batch file is more than enough, here is a good resource
    :q :q! :wq :w :w! :wq! :quit :quit! :help help helpquit quit quithelp :quitplease :quitnow :leave :**** ^X^C ^C ^D ^Z ^Q QUITDAMMIT ^[:wq GCS,M);d@;p;c++;l++;u ++ ;e+ ;m++(---) ;s+/+ ;n- ;h* ;f+(--) ;!g ;w+(-) ;t- ;r+(-) ;y+(**)

  4. #4
    Senior Member tampabay420's Avatar
    Join Date
    Aug 2002
    Posts
    953
    Code:
    cd \\System123\File321
    dir *.XzY /s >> dir.txt
    dir *.ZyX /s >> dir.txt
    dir *.XyZ /s >> dir.txt
    cd \\System234\File321
    dir *.XzY /s >> dir.txt
    dir *.ZyX /s >> dir.txt
    dir *.XyZ /s >> dir.txt
    This would work>?
    yeah, I\'m gonna need that by friday...

  5. #5
    Senior Member Info Tech Geek's Avatar
    Join Date
    Jan 2003
    Location
    Vernon, CT
    Posts
    828
    Oh, Wait... This won't work. I'm looking for text, not files.

    Originally posted here by Info Tech Geek
    (this is for text within the file, not by file name)
    would you be able to search for a string and copy the results to the file?

  6. #6
    Senior Member
    Join Date
    Sep 2001
    Posts
    1,027
    Dunno if this utility is on win95/98, but on 2K (and presumably XP):
    find /?

    Ammo
    Credit travels up, blame travels down -- The Boss

  7. #7
    Senior Member tampabay420's Avatar
    Join Date
    Aug 2002
    Posts
    953
    ammo is correct, if you're trying to find text (plain text) within a file... use the Find command in t he batch... if you are looking for filename/extensions then use my example (dir)...

    from D0S
    Searches for a text string in a file or files.

    FIND [/V] [/C] [/N] [/I] "string" [[drive:][path]filename[ ...]]

    /V Displays all lines NOT containing the specified string.
    /C Displays only the count of lines containing the string.
    /N Displays line numbers with the displayed lines.
    /I Ignores the case of characters when searching for the string.
    "string" Specifies the text string to find.
    [drive:][path]filename
    Specifies a file or files to search.

    If a path is not specified, FIND searches the text typed at the prompt
    or piped from another command.
    yeah, I\'m gonna need that by friday...

  8. #8
    Senior Member
    Join Date
    Oct 2001
    Posts
    748
    I prefer findstr. Has more options.

    X:\>findstr /?
    Searches for strings in files.

    FINDSTR [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file]
    [/C:string] [/G:file] [/D:dir list] [/A:color attributes]
    [strings] [[drive:][path]filename[ ...]]

    /B Matches pattern if at the beginning of a line.
    /E Matches pattern if at the end of a line.
    /L Uses search strings literally.
    /R Uses search strings as regular expressions.
    /S Searches for matching files in the current directory and all
    subdirectories.
    /I Specifies that the search is not to be case-sensitive.
    /X Prints lines that match exactly.
    /V Prints only lines that do not contain a match.
    /N Prints the line number before each line that matches.
    /M Prints only the filename if a file contains a match.
    /O Prints character offset before each matching line.
    /P Skip files with non-printable characters
    /A:attr Specifies color attribute with two hex digits. See "color /?"
    /F:file Reads file list from the specified file(/ stands for console).
    /C:string Uses specified string as a literal search string.
    /G:file Gets search strings from the specified file(/ stands for console).
    /D:dir Search a semicolon delimited list of directories
    strings Text to be searched for.
    [drive:][path]filename
    Specifies a file or files to search.

    Use spaces to separate multiple search strings unless the argument is prefixed
    with /C. For example, 'FINDSTR "hello there" x.y' searches for "hello" or
    "there" in file x.y. 'FINDSTR /C:"hello there" x.y' searches for
    "hello there" in file x.y.

    Regular expression quick reference:
    . Wildcard: any character
    * Repeat: zero or more occurances of previous character or class
    ^ Line position: beginning of line
    $ Line position: end of line
    [class] Character class: any one character in set
    [^class] Inverse class: any one character not in set
    [x-y] Range: any characters within the specified range
    \x Escape: literal use of metacharacter x
    \<xyz Word position: beginning of word
    xyz\> Word position: end of word

    For full information on FINDSTR regular expressions refer to the online Command
    Reference.

  9. #9
    Senior Member Info Tech Geek's Avatar
    Join Date
    Jan 2003
    Location
    Vernon, CT
    Posts
    828
    I want to search \\System123\File321 (and all subdirectories)
    For the work XyZ in all files in all subdirectories and then search for word ZyX and so on. I want the filename containing these words to be printed out to a list in which I can examine. Or better yet, back up these files to another directory or something along those lines.

  10. #10
    Senior Member Info Tech Geek's Avatar
    Join Date
    Jan 2003
    Location
    Vernon, CT
    Posts
    828
    would it be possible to do a find using the MS feature find, save the find, and type a batch to recall the find feature from the saved information??? Where would this information be stored once it is saved?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides