Windows 8 and 8.1 Forums


Find two or more strings in an output

  1. #1

    Find two or more strings in an output


    Hi

    In the command prompt in Windows 8.x, the output of the dir command produces a list of all files and directories with their information.

    If I wanted to display only the output of only two or three files (including their information), how should I do?

    Note: These files, that I should see, have completely different names.

    Thanks

    Bye

      My System SpecsSystem Spec

  2. #2


    I don't believe that is possible. The command line supports wildcards but that does not allow for selection of totally unrelated names.
      My System SpecsSystem Spec

  3. #3


    Posts : 454
    Windows 8.1 Pro with Media Center


    The Unix way would be to pipe dir's output to grep. You can do this at the Windows command prompt provided you have a suitable search program. PowerShell may have such a feature.
      My System SpecsSystem Spec

  4. #4


    Install Unxtools then you have Grep and most of the other neat Unix/Linux tools.

    I use grep and tee fairly often.

    Having said the above, I don't think grep will do what you want as it only accepts one "pattern". You can't say "pattern1" or "pattern2".
      My System SpecsSystem Spec

  5. #5


    Posts : 454
    Windows 8.1 Pro with Media Center


    Quote Originally Posted by Ztruker View Post
    Having said the above, I don't think grep will do what you want as it only accepts one "pattern". You can't say "pattern1" or "pattern2".
    I was using "grep" in the generic sense. There are three programs in the grep family, grep, egrep, and fgrep. GNU grep subsumed all three, and the various modes are enabled by program options, though distros arrange that you can still say "egrep" and "fgrep". The egrep variant provides full regexp and is the most versatile, though fgrep is useful for searching on a collection of fixed strings (which egrep can also do).
      My System SpecsSystem Spec

  6. #6


    Any chance you can provide an example of searching for two strings in the output from the dir command?
      My System SpecsSystem Spec

  7. #7


    Posts : 2,130
    Windows 8.0 x64


    Linux type Find command may work. Or a simple ahk directed at the explicit filenames(if they will always be the same.)
    For example

    Code:
    Loop c:\folder\*.*
    {
    if %A_LoopFilename% in filenameone,filenametwo,filename3
      do something
    }
      My System SpecsSystem Spec

  8. #8


    This has to run on Windows. Loop is an unknown command in Windows, even with UnxTools installed.
      My System SpecsSystem Spec

  9. #9


    Posts : 454
    Windows 8.1 Pro with Media Center


    Quote Originally Posted by Ztruker View Post
    Any chance you can provide an example of searching for two strings in the output from the dir command?
    Assuming you have egrep:

    Code:
    dir | egrep -i "this|that"
    If you're not fixated on the command line, programs like Xyplorer support regexp finds, and I suppose you could get by with redirecting dir's output to a text file and searching the contents with Notepad++ or similar.

    Quote Originally Posted by Ztruker View Post
    This has to run on Windows. Loop is an unknown command in Windows, even with UnxTools installed.
    He was talking about Autohotkey.
      My System SpecsSystem Spec

  10. #10


    Posts : 2,130
    Windows 8.0 x64


    More detail would help. With the current info it could just as well be accomplished with batch. Something like

    Code:
    For %s in (%1 %2 %3 %4) do {
    dir %s >> results.txt
    echo. >> results.txt
    }
    Some experimenting should do it
    For - Looping commands | Windows CMD | SS64.com

    name the batch DirThese.cmd
    usage
    DirThese fileone.txt file2.exe file3.xml

    ( or even better, use Shift to process as many files as you type on command tail )
      My System SpecsSystem Spec

Page 1 of 2 12 LastLast
Find two or more strings in an output
Related Threads
My KONICA MINOLTA magicolor 1690mf network printer can't print . While i printing the output file is .prn . How can i reslove ?
No audio input and output in Sound & Audio
Well, things went on until noon yesterday, but suddenly My PC takes no audio input or gives any output. I have tried reinstalling driver, checking mute button, checking Cables etc, none of the audio devices work on my PC which work in other devices. On opening realtek audio manager and playing...
HDMI output not working in Graphic Cards
Hey guys, I have an ASUS s550C running windows 8 and my HDMI to my 32" RCA flatscreen doesn't work anymore. The cable works fine with the xbox, correct tv modes, but now as soon as I plug in the HDMI to the Ultrabook the Ultrabooks screen goes black and the tv screen says unsupported. What gives?...
Okay so, my computer recently crashed and had to reformat it.. lost everything :( Everything was working just fine, until I had to reformat. Now, I have no sound at all coming from my headphones and it says that the AMD HDMI Output is not plugged in. I don't really know how to fix this.. ...
Solved Multiple BSOD Bug Check Strings in BSOD Crashes and Debugging
I have had at least 5 different bug check strings. This is the most recent one: A problem has been detected and Windows has been shut down to prevent damage to your computer. The problem seems to be caused by the following file: ntoskrnl.exe KERNEL_DATA_INPAGE_ERROR
help with output of SFC /Scannow from CBS.log in Performance & Maintenance
Based on the snippet I've included below from running sfc/scannow there seems to be a problem with Task Scheduler.lnk. The thing is TS is working fine and the hashes of the file are the same in the folders indicated. While not earth shattering I wonder if anyone can shed some light into what...
Eight Forums Android App Eight Forums IOS App Follow us on Facebook