Tom's Hardware > Forum > Windows XP > Windows XP General Discussion > Command Line string search

Command Line string search

Forum Windows XP : Windows XP General Discussion - Command Line string search

Tom's Hardware: Over 1.4 million members in 6 different countries available to answer all your high-tech questions. Sign up now! Its free!
Word :    Username :           
 

Archived from groups: microsoft.public.windowsxp.general (More info?)

 

Hello to all,

I need help with the following please.

[OS = XP Pro]

I want to print to file, a list of files in a specific directory that
contain a certain string. This listing must also include the date of said
file.

I'm able to create the list of files with FINDSTR /M
[[drive:][path]filename]. This returns all the fiile names which meet the
criteria but FINDSTR does not return the date of the file, which I also need.

I thought I may be able to use the FOR and or DIR commands in conjunction
with FINDSTR and pipe this to a text file. I've been reading the help file on
FOR but it is not clear to me how to use the results from FINDSTR as an input
variable.

Any help in setting me on the correct path to solving this is greatly
appreciated.

Regards,

Hal
Michigan, USA

Sponsored Links
Register or log in to remove.

Archived from groups: microsoft.public.windowsxp.general (More info?)

 

"Hal" <Hal@discussions.microsoft.com> wrote in message
news:D4D6BEDD-ED63-4388-A95D-BE63CA820011@microsoft.com...
> Hello to all,
>
> I need help with the following please.
>
> [OS = XP Pro]
>
> I want to print to file, a list of files in a specific directory that
> contain a certain string. This listing must also include the date of said
> file.
>
> I'm able to create the list of files with FINDSTR /M
> [[drive:][path]filename]. This returns all the fiile names which meet the
> criteria but FINDSTR does not return the date of the file, which I also
need.
>
> I thought I may be able to use the FOR and or DIR commands in conjunction
> with FINDSTR and pipe this to a text file. I've been reading the help file
on
> FOR but it is not clear to me how to use the results from FINDSTR as an
input
> variable.
>
> Any help in setting me on the correct path to solving this is greatly
> appreciated.
>
> Regards,
>
> Hal
> Michigan, USA

How about this:

dir /ad "c:\SomeFolder\Some Subfolder" | find /i "Some String" >
c:\FileList.txt

You don't really need the FOR command in this case but here is
how you could use it in a batch file:

Line1 @echo off
Line2 SetLocal EnableDelayedExpansion
Line3
Line4 set count=0
Line5 for /F "tokens=*" %%* in ('dir /ad "c:\SomeFolder\SomeSubfolder" ^|
find /i "SomeString"') do (
Line6 set Line=%%*
Line7 set count=!count! + 1
Line8 echo Line !count!=!Line!
Line9 )
Line10 EndLocal

Reply to Anonymous
Tom's Hardware > Forum > Windows XP > Windows XP General Discussion > Command Line string search
Go to:

There are 569 identified and unidentified users. To see the list of identified users, Click here.

Please mind

You are about to answer a thread that has been inactive for more than 6 months.
If you still wish to proceed, please ensure that your posting is original and does not duplicate or overlap any prior responses to this thread.

Add a reply Cancel
Sponsored links
  • Ask the community now
  • Publish
Ad
They won a badge
Join us in greeting them