Remove unwanted path name from %path% variable via batch

This removes the substring C:\Program Files (x86)\Git\bin; from the PATH string and re-assigns:

set PATH=%PATH:C:\Program Files (x86)\Git\bin;=%

You might use this to see the change:

echo %PATH:C:\Program Files (x86)\Git\bin;=% | tr ; \n

Note: be exact on the substring. It's case-sensitive and slash-sensitive.

If you need to make it a persistent change use setx instead of set and open another console for changes to take effect.

setx /M PATH "%PATH:C:\Program Files (x86)\Git\bin;=%"

You can try something like this :

@echo off&cls
setlocal EnableDelayedExpansion
set $line=%path%
set $line=%$line: =#%
set $line=%$line:;= %

for %%a in (%$line%) do echo %%a | find /i "oracle" || set $newpath=!$newpath!;%%a
set $newpath=!$newpath:#= !
echo set path=!$newpath:~1!

I putted an echo to the last line. Check the result and If it's OK for you, remove it.