Find two or more strings in an output

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
balubeto
Posts: 136
Joined: 08 Dec 2011 12:14

Find two or more strings in an output

#1 Post by balubeto » 20 Apr 2015 04:38

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

Yury
Posts: 115
Joined: 28 Dec 2013 07:54

Re: Find two or more strings in an output

#2 Post by Yury » 20 Apr 2015 05:22

Code: Select all

@echo off

set "dir=C:\Test"
set filenames="1.txt" "3.txt" "5.txt"

pushd "%dir%"|| exit/b
dir %filenames%| findstr/brv /c:" " /c:$
popd

pause

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Find two or more strings in an output

#3 Post by dbenham » 20 Apr 2015 10:00

You can specify multiple files, or file masks with wildcards on a single DIR command.

Code: Select all

dir file1.txt file2.exe file3.dat


Dave Benham

Post Reply