remove string between \****\abcdefghijklm

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

remove string between \****\abcdefghijklm

#1 Post by goodywp » 17 Oct 2017 11:49

Hi all
I have a task like below:

input:

\T501-08680-0101-T3_Mockup_Generic_Scheme_Pack\T501-08680-0101\Application_Signing\Signed_Schemes\MockupSigned_T3\500007011000.S3S”


output:
\T501-08680-0101\Application_Signing\Signed_Schemes\MockupSigned_T3\500007011000.S3S”

Basically I would like to trim off the string from beginning \ and before next \ , like this case:
trim off:
\T501-08680-0101-T3_Mockup_Generic_Scheme_Pack

and this string is sometime longer or shorter...so we can not used fixed characters to do the job...

Any clue we can use \ and \ to trim off the string in between...

Thanks

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: remove string between \****\abcdefghijklm

#2 Post by ShadowThief » 17 Oct 2017 11:59

When you use a wildcard with for loop tokens, the delimiter remains in the token handled by the wildcard. All you have to do is split the string on \ and just return the second token.

Code: Select all

for /f "tokens=1,* delims=\" %%A in ("\T501-08680-0101-T3_Mockup_Generic_Scheme_Pack\T501-08680-0101\Application_Signing\Signed_Schemes\MockupSigned_T3\500007011000.S3S”) do echo %%B

goodywp
Posts: 265
Joined: 31 Jul 2017 09:57

Re: remove string between \****\abcdefghijklm

#3 Post by goodywp » 18 Oct 2017 08:17

Thanks ShadowThief!!

Post Reply