Computing.Net > Forums > Programming > Finstr command in Dos

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Finstr command in Dos

Reply to Message Icon

Name: ekks
Date: May 8, 2006 at 07:36:23 Pacific
OS: Win2000
CPU/Ram: 2.5 gig
Product: Dell
Comment:

Trying to write a bat file to search all files in a directory for a certain string and copy the files that contain it to another directory. ...I've never written a bat file before. I've got the findstr command to list out the files but can't feed that list to the copy command. Can someone help?




Sponsored Link
Ads by Google

Response Number 1
Name: ekks
Date: May 8, 2006 at 07:46:31 Pacific
Reply:

This is my findstr command...I just can't redirect the output from the screen to another command. I can direct it to a txt file though.


0

Response Number 2
Name: ekks
Date: May 8, 2006 at 09:16:49 Pacific
Reply:

findstr /M "<SRVC_INST_ID>23</SRVC_INST_ID>" c:\HawaiianTelecom\rl\*.*


0

Response Number 3
Name: Mechanix2Go
Date: May 8, 2006 at 12:13:11 Pacific
Reply:

If it's w2k and not DOS, this should help:

::== findcopy.bat
@echo off

for %%T in (c:\HawaiianTelecom\rl\*.*) do (
find "<SRVC_INST_ID>23</SRVC_INST_ID>" %%T > nul
if errorlevel 1 goto :eof
echo copy %%T d:\stuff
)
:: DONE



If at first you don't succeed, you're about average.

M2


0

Response Number 4
Name: ekks
Date: May 8, 2006 at 16:39:56 Pacific
Reply:

Thanks I'll give that a try.


0

Response Number 5
Name: ekks
Date: May 9, 2006 at 07:55:47 Pacific
Reply:

This works up till it finds a file that fails then it stops without finishing the rest of the folder. Any Suggestions?


0

Related Posts

See More



Response Number 6
Name: Mechanix2Go
Date: May 9, 2006 at 10:28:38 Pacific
Reply:

Hi,

You're right. I was wrong. My apology for that.

I think this will get it:

::== findcop2.bat
@echo off

for %%T in (c:\HawaiianTelecom\rl\*.*) do call :sub1 %%T
goto :eof

:sub1
find "<SRVC_INST_ID>23</SRVC_INST_ID>" %1 > nul
if errorlevel 1 goto :eof
echo copy %1 d:\stuff
goto :eof
:: DONE



If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Finstr command in Dos

"TYPE" DOS commands in C www.computing.net/answers/programming/type-dos-commands-in-c-/16874.html

Unix commands in Command prompt? www.computing.net/answers/programming/unix-commands-in-command-prompt/15282.html

DOS commands in C www.computing.net/answers/programming/dos-commands-in-c/9449.html