Checking for strings within a variable
Posted on 2008-06-12
I'm working on a batch file that will perform a search and destroy on shortcuts. It works great, but I need it to be smarter. Here is the current script:
FOR /R %%A IN (.) DO CALL :COMMAND "%%A"
FOR /F "usebackq delims=" %%A in (`DIR /B *"%TARGET%"*.lnk 2^>NUL`) DO CALL :DELETE "%%A"
echo Deleting %CD%\%LOCALVAR% >> \\tbcsrv903\office2007\logs\%COMPUTERNAME%\installstatus.txt
I change to the c:\documents and settings\ folder and call the batch file
Example: findndel.bat word
It then searches the documents and settings folder for all shortcuts with "word" in them and deletes them.
Here's the catch. When it finds them I want it to ignore shortcuts with, say, "2007" or "web" or "pad".
Is there any way to have it check to see if the LOCALVAR variable contains any of these strings, and if so, skip the delete command?