![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-03 21:29 |
48,038 topics / 350,123 posts / today 0 new / 48,251 members |
| DOS批处理 & 脚本技术(批处理室) » Looking for an old thread with a very detailed explanation of set! |
| Printable Version 809 / 2 |
| Floor1 peterdocter | Posted 2007-03-25 12:34 |
| 中级用户 Posts 95 Credits 379 | |
|
I think the poster was lxmxn?
It analyzed set substring extraction by position in great detail. I forget whether it used %time% or %date% or a string as the example! The rough content was like this: set=1234567890 Take the first character 1, the second 2, the third 3, and so on... I think it also talked about replacing content... Now I can't find that thread anywhere |
|
| Floor2 slore | Posted 2007-03-25 12:39 |
| 铂金会员 Posts 2,478 Credits 5,212 | |
|
set /? seems to have it
Environment variable substitution has been enhanced as follows: %PATH:str1=str2% This expands the PATH environment variable, replacing each occurrence of "str1" in the expanded result with "str2". To effectively delete all occurrences of "str1" from the expanded result, "str2" can be empty. "str1" can begin with an asterisk; in that case, everything from the beginning of the expanded result up to the first occurrence of the remainder of str1 is kept matched. You can also specify substrings for the expansion. %PATH:~10,5% This expands the PATH environment variable, then uses only the five characters starting with the 11th character (offset 10) in the expanded result. If length is not specified, the default value is the remainder of the variable value. If both numbers (offset and length) are negative, the numbers used are the length of the environment variable value plus the specified offset or length. %PATH:~-10% This extracts the last ten characters of the PATH variable. %PATH:~0,-2% This extracts all characters of the PATH variable except the last two. |
|
| Floor3 lxmxn | Posted 2007-03-25 13:24 |
| 版主 Posts 4,938 Credits 11,386 | |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |