Substring by Variale

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Yossi Moses
Posts: 3
Joined: 14 Nov 2013 07:30

Substring by Variale

#1 Post by Yossi Moses » 14 Nov 2013 07:46

Dear freinds
The following is very tivial:

Code: Select all

%PATH:~10,5%
(from SET command help)
I don't have the 10 and 5 as constants but in Vars, so, I try this and of course it doesn't work
(Where x is for the 10 and y is for the 5)

Code: Select all

%PATH:~%x%,%y%%

Thank you very much for Suggestions

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

Re: Substring by Variale

#2 Post by ShadowThief » 14 Nov 2013 08:19

Code: Select all

setlocal enabledelayedexpansion

!PATH:~%x%,%y%!

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Substring by Variale

#3 Post by dbenham » 14 Nov 2013 08:36

Or, in the rare instances when delayed expansion cannot be used:

Code: Select all

call echo %%path:~%x%,%y%%%


Dave Benham

Post Reply