Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
ankycooper9
- Posts: 2
- Joined: 26 Mar 2012 03:27
#1
Post
by ankycooper9 » 26 Mar 2012 03:33
Let say I have 2 variables
Code: Select all
set var1=hello:\how\areyou.i'mgr8
set var2=hello:\how\are
now I have to remove contents of var2 from var1
(The desired result in the above example would be var1=you.i'mgr8 )
I have ftied the following but does not work
Please help
-
dbenham
- Expert
- Posts: 2461
- Joined: 12 Feb 2011 21:02
- Location: United States (east coast)
#2
Post
by dbenham » 26 Mar 2012 04:43
If you are in a situation where you cannot use immediate expansion, then:
Code: Select all
@echo off
setlocal enableDelayedExpansion
(
set var1=hello:\how\areyou.i'mgr8
set var2=hello:\how\are
for /f "delims=" %%S in ("!var2!") do set var1=!var1:%%S=!
)
Dave Benham
-
!k
- Expert
- Posts: 378
- Joined: 17 Oct 2009 08:30
- Location: Russia
#3
Post
by !k » 26 Mar 2012 07:14