Page 1 of 1

Strip first 3 characters and replace the last?

Posted: 15 Dec 2016 14:35
by SIMMS7400
Hi Folks -

I have a variable called %MAINPATH% which is the following:

SET MAINPATH=C:\Hyperion_Batch\

What I need to do is strip the first 3 characters (C:\) and replace the last (\) with /. Can this be done in 1 fell swoop? Thanks!

Re: Strip first 3 characters and replace the last?

Posted: 15 Dec 2016 16:06
by Squashman
Think about what you can do with the for variable modifiers or even just using the slash as a delimiter.

Re: Strip first 3 characters and replace the last?

Posted: 16 Dec 2016 06:49
by Aspidiske
Yes

set mainpath=%mainpath:~3,-1%/