search for list of filenames in a single file
Moderator: DosItHelp
search for list of filenames in a single file
Hi
Need help to search for list of filenames in a single file.
Lets say the file information.txt contains lakhs of filenames but i only need to get a list of hundred filenames with all the instances in that file.
lets say information.txt contains
1 1.txt
2 2.txt
3 3.txt
4 2.txt
5 4.txt
6 5.txt
7 2.txt
8 6.txt
9 2.txt
10 1.txt
if the search criteris is "1.txt" and "2.txt"
the output should be
start
=================
1 1.txt
2 2.txt
4 2.txt
7 2.txt
9 2.txt
10 1.txt
=====================
end
the same should be applicable for any no of files with any no of instances as in this case we have only 2 files as our search criteria.
Regards
Ladduq
Need help to search for list of filenames in a single file.
Lets say the file information.txt contains lakhs of filenames but i only need to get a list of hundred filenames with all the instances in that file.
lets say information.txt contains
1 1.txt
2 2.txt
3 3.txt
4 2.txt
5 4.txt
6 5.txt
7 2.txt
8 6.txt
9 2.txt
10 1.txt
if the search criteris is "1.txt" and "2.txt"
the output should be
start
=================
1 1.txt
2 2.txt
4 2.txt
7 2.txt
9 2.txt
10 1.txt
=====================
end
the same should be applicable for any no of files with any no of instances as in this case we have only 2 files as our search criteria.
Regards
Ladduq
-
- Posts: 14
- Joined: 20 Mar 2012 10:07
Re: search for list of filenames in a single file
C:\temp>findstr "1.txt 2.txt" information.txt
1 1.txt
2 2.txt
4 2.txt
7 2.txt
9 2.txt
10 1.txt
C:\temp>
1 1.txt
2 2.txt
4 2.txt
7 2.txt
9 2.txt
10 1.txt
C:\temp>
Re: search for list of filenames in a single file
@tonysathre
That search will be treated as a regex, and the dot will match any character. Not what is wanted.
You need to add the /L (literal) option to the findstr command.
Also, you can't search for file names that contain spaces that way. For spaces you need the /c:"search" option.
Dave Benham
That search will be treated as a regex, and the dot will match any character. Not what is wanted.
You need to add the /L (literal) option to the findstr command.
Also, you can't search for file names that contain spaces that way. For spaces you need the /c:"search" option.
Dave Benham
-
- Posts: 14
- Joined: 20 Mar 2012 10:07
Re: search for list of filenames in a single file
I thought that regex was only used when you specify /R. Is that not the case?
Tony
Tony
Re: search for list of filenames in a single file
No, it defaults to regex
Good one Microsoft. Nice of them to include a /R switch.
Good one Microsoft. Nice of them to include a /R switch.
Re: search for list of filenames in a single file
tonysathre wrote:C:\temp>findstr "1.txt 2.txt" information.txt
1 1.txt
2 2.txt
4 2.txt
7 2.txt
9 2.txt
10 1.txt
C:\temp>
You should search for " 1.txt" so 11.txt or 101.txt are excluded. (of course with /C as others already mentioned).
Saso
Re: search for list of filenames in a single file
That's normal. What are you trying to say?
Re: search for list of filenames in a single file
it's no regexps
Re: search for list of filenames in a single file
Code: Select all
@echo off
type nul> "Crystal Reports Shifts01.pdf"
type nul> "Crystal Reports Shifts02.pdf"
type nul> "Crystal Reports Shifts03.pdf"
type nul> "Crystal Reports Shifts04.pdf"
dir /b |findstr ..pdf
del "Crystal Reports Shifts0?.pdf"
pause
Re: search for list of filenames in a single file
With the literal string /c: switch it switches to literal mode.