There is an ability to return a partial string from an environment variable in batch programming, but I've been unable to find any reference to it on the net.
This is the standard usage of an environment variable:
C:\>echo %DATE%
Fri 08/19/2005
But, from a quick clue offered on an old post out on the net, I've learned that following the variable's name with a colon and tilde (":~") and a number, you can specify a number of characters to be dropped from the left end of the string. Hence:
C:\>echo %DATE:~4%
08/19/2005
Place a minus sign in front of the number, and you're now specifying the number of characters to use from the right end of the string:
C:\>echo %DATE:~-10%
08/19/2005
That's as much as I've been able to glean with trial and error. I can't find any documentation on this, neither on the internet, nor in the MS help files and knowledge base, though I can't be certain that I'm searching for the correct terms.
Does anyone have any information on this? Ultimately, I'm hoping there's an ability to specify the number of characters from the left end of the string that I'd like returned instead of dropped.
David Marcus
New York, NY
This is the standard usage of an environment variable:
C:\>echo %DATE%
Fri 08/19/2005
But, from a quick clue offered on an old post out on the net, I've learned that following the variable's name with a colon and tilde (":~") and a number, you can specify a number of characters to be dropped from the left end of the string. Hence:
C:\>echo %DATE:~4%
08/19/2005
Place a minus sign in front of the number, and you're now specifying the number of characters to use from the right end of the string:
C:\>echo %DATE:~-10%
08/19/2005
That's as much as I've been able to glean with trial and error. I can't find any documentation on this, neither on the internet, nor in the MS help files and knowledge base, though I can't be certain that I'm searching for the correct terms.
Does anyone have any information on this? Ultimately, I'm hoping there's an ability to specify the number of characters from the left end of the string that I'd like returned instead of dropped.
David Marcus
New York, NY