Page 1 of 1

remove string between \****\abcdefghijklm

Posted: 17 Oct 2017 11:49
by goodywp
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

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

Posted: 17 Oct 2017 11:59
by ShadowThief
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

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

Posted: 18 Oct 2017 08:17
by goodywp
Thanks ShadowThief!!