I don't think this addresses your issue but seems generally relevant and maybe useful to know.
Substrings can be removed using the idiom below.
set PATH=%PATH:C:\perls\strawberry-perl-5.32.1.1-64bit-portable\perl\b +in;=%
A looped example and some gotchas are in this SO post.
In reply to Re: Cleaning %PATH% with WinBatch
by swl
in thread Cleaning %PATH% with WinBatch
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |