I'm having issues writing code to find and replace strings in text files. I'm in the middle of doing my taxes so I'd figure I'd put this up so someone can take a look at it in the mean time.
Here is what I have:
rename "Dynamic Campaign\BATCHES\BATCH_SCR.bat" BATCH_SCR.tmp
set /p this=E:\Program Files (x86)\Ubisoft\SilentHunterIII
for /f "tokens=*" %%a in ("Dynamic Campaign\BATCHES\BATCH_SCR.tmp") do (
set foo=%%a
if %%a==!this! set foo=!sh3directory!
echo !foo!>> "Dynamic Campaign\BATCHES\BATCH_SCR.bat"
)
del "Dynamic Campaign\BATCHES\BATCH_SCR.tmp" /q
pause
!this! is the variable that I am trying to find (string trying to find)
!sh3directory! is the string I want to replace it with.
Yes, sh3directory is assigned correctly.
Notice both variables are filepaths.
Thank you.