Newsgroups: alt.msdos.batch.nt
From: Clay Calvert <ccalv...@wanguru.com>
Date: Sun, 25 Mar 2001 10:50:03 -0500
Local: Sun, Mar 25 2001 10:50 am
Subject: Re: string manipulation in a batch file...
On Sun, 25 Mar 2001 09:26:14 GMT, "D'oh" <aa...@chebucto.ns.ca> wrote: SET %Var%=%Var:str1=str2% is the syntax for string replacement in NT >It is my understanding that Windows 2000 (possibly NT?) has finally >introduced some string manipulating capabilities. Do any of you know of any >good sites that give an overview/examples of this? I've searched the net >but have come up empty (which doesn't surprise me....I can't seem to find >anything anymore :). >Right now what I want to do is pretty simple (search for a substring [which >Thanks, >Greg and Win2K. Set WeekDay=Monday The following are examples of variable substitution and parsing in A "#" character will indicate functionality only available in Windows More information can be found from running "Set /?" and "For /?". A "one-sided" variable is a single character variable that has a Examples: %1 and %a "Two-sided" variables can have more than one character and have a %PATH:str1=str2% Substitution [: and =] Two sided only %Test:ab=xy% 123456789xycdef0 [%:~X and %:~X,Y] Two sided variables only The following string will be used for these examples: Grab only the first 5 characters Skip 7 characters and then grab the next 5 Skip 7 characters and then grab everything else Grab only the last 7 characters # Grabs everything BUT the last 7 characters # Grab between 7 from the front and 5 from the back # Go back 7 from the end then grab 5 towards the end # Grab between 7 from the end and 5 from the end # [%~letter] One sided variables only %~I removes any surrounding quotes (") [%~$string] Two-sided The modifiers can be combined to get compound results: %~dpI - expands %I to a drive letter and path only In the above examples %I and PATH can be replaced by other valid Clay Calvert You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||