> The first part is easy. Let's say the text string I want to
> search for is "elephant". Ok, the line that does this is:
>
> find /f elephant c:\directoryname\*.txt > zoo.txt
>
> This will give me a plain text file that is a list of all the
> files that contain the string "elephant" in a file called zoo.txt
Well, OK, but why bother? Do this:
<-- Cut and remove footnote markers -->
@ECHO OFF [0]
IF %1!==! GOTO ERROR
IF %2!==CHECK! GOTO CHECKING
FOR %%A IN (%1) DO CALL %0 %%A CHECK [1]
GOTO END
:ERROR
ECHO You need to give me a wildcard filespec!
ECHO e.g. %0 *.TXT
GOTO END
:CHECKING
FIND elephant %1
IF ERRORLEVEL 1 DEL %1 [2]
:END
<-- Cut -->
[0] For MS-DOS < 3.3 (or equivalent) use ECHO OFF
[1] For MS-DOS < 3.3 (or equivalent) use ... COMMAND /C %0.BAT %%A CHECK
[2] Might be IF NOT ERRORLEVEL 1 - I always forget whether FIND gives 1 for
found or not found.
Run this batch file with a filespec like *.TXT and it'll look for the
string elephant in all those files and delete either those with or those
without it (depending on which way round I have the IF ERRORLEVEL line).
It won't check subdirectories - that could be done with an extra level of
recursion but life's too short.
Regards, Web: http://www.geocities.com/SiliconValley/Horizon/8786
Ben A L Jemmett ICQ: 9848866 JGSD e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------------
'<INSERT SOME CORNY QUOTE HERE>'
--------------------------------------------------------------------------
To unsubscribe from SURVPC send a message to [EMAIL PROTECTED] with
unsubscribe SURVPC in the body of the message.
Also, trim this footer from any quoted replies.