InterviewSolution
Saved Bookmarks
| 1. |
Solve : How to copy a portion of a string of text? XP cmd file? |
|
Answer» HELLO, I have a command file that I'm trying to select a part of a string. Let say I have WindowsXP-KB123456-X86.exe. I WANT to copy just the KB123456 and shove it into a variable to be used later. I have been poking around the net with no luck. Any suggestions? Kage_To slice a string USE the following syntax:- set substring=%wholestring:~X,Y% where X and Y are numbers. X is the offset from the start -- 0 (ZERO) is the first character -- and Y is the number of characters to take. so if bigstring=Australia %bigstring:~0,4% is Aust and %bigstring:~2,5% is ustraVery nice! I love it when there's a nice simple answer to questions. This works great... Thanks....I was off by 1 in my second example string slice. ustra is 1,5 not 2,5. Please see modified below Quote from: Dias de verano on October 17, 2008, 03:58:40 PM so if bigstring=AustraliaThanks for the correction. I was able to understand what it was doing. It's now in my cmd file and has saved me a lot of lines of redundant CODE. |
|