|it's the () that are killing you. These are highly toxic to batchscript.|
Lethal, unless precautions are taken. Thankyou, MS, for putting all this garbage into filenames. Blessings.
This worked on your sample: (left all debugging crap in place.)
@ECHO OFF & setlocal enabledelayedexpansion
:first, wrap the variable in quotes to insulate against the parentheses.
set pathString="C:\Program Files (x86)\company\product\apache-tomcat-7.0.12\webapps\gc\WEB-INF\lib;c:\test2;"
set search1="C:\Program Files (x86)\company\product\apache-tomcat-7.0.12\webapps\gc\WEB-INF\lib;"
echo %pathString% | find %search1%
echo ERRLVL: %errorlevel%
IF %ERRORLEVEL%==0 (
rem the following line is what I'm having trouble with. All examples I have seen are using static text, but I need to replace the contents of variable 1 where variable 2 is found and remove it.
:now we gotta get rid of the quotes, hence this next set of code
for /f "tokens=*" %%b in (%search1%) do set f1=%%~b
echo f1 IS: !f1!
for /f "tokens=*" %%c in (%pathstring%) do set f2=%%~c
echo f2 is: !f2!
echo in edit, f1=%f1%
it worked on xp, but not tested on seven.