Strip first 3 characters and replace the last?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
SIMMS7400
Posts: 546
Joined: 07 Jan 2016 07:47

Strip first 3 characters and replace the last?

#1 Post by SIMMS7400 » 15 Dec 2016 14:35

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!

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Strip first 3 characters and replace the last?

#2 Post by Squashman » 15 Dec 2016 16:06

Think about what you can do with the for variable modifiers or even just using the slash as a delimiter.

Aspidiske
Posts: 7
Joined: 30 Oct 2016 09:48

Re: Strip first 3 characters and replace the last?

#3 Post by Aspidiske » 16 Dec 2016 06:49

Yes

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

Post Reply