中国DOS联盟论坛

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-12 03:09
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » Problems with %~fsi in the for statement???
Printable Version  1,574 / 8
Floor1 sunyao Posted 2006-11-29 06:20
初级用户 Posts 60 Credits 141 From 天津
I looked up for /?
%~fsI is to expand %I to the full path name containing only the short name.
Through experimentation
SET WL_HOME=C:\bea\weblogic91
FOR %%i IN ("%WL_HOME%") DO SET WL_HOME=%%~fsi
echo %WL_HOME%
pause
It shows WL_HOME=C:\bea\WEBLOG~1
I don't know how to explain the sentence "expand %I to the full path name containing only the short name"
Let's explain: In Windows, for a long file or directory name, there is a corresponding short name. For example, "weblogic91" has a short name "WEBLOG~1". When using %~fsI in a for loop, it takes the variable %I (here it's "%WL_HOME%") and expands it to the full path but using the short name part. So in the example, %WL_HOME% is "C:\bea\weblogic91", and when processed with %%~fsi, it becomes the full path with the short name part, so it's "C:\bea\WEBLOG~1".
Floor2 lxmxn Posted 2006-11-29 06:59
版主 Posts 4,938 Credits 11,386

You can understand it this way. If %i refers to a file, then %~fsi refers to the path and short filename of this file. This process is called expansion.
Floor3 sunyao Posted 2006-11-29 23:00
初级用户 Posts 60 Credits 141 From 天津
What is the definition of the so-called short filename? C:\bea\weblogic91 How does it become C:\bea\WEBLOG~1?
Floor4 ccwan Posted 2006-11-30 01:17
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
What I "Baidu" for you:

Floor5 ccwan Posted 2006-11-30 01:23
金牌会员 Posts 1,160 Credits 2,725 From 河北廊坊
Here's the translation:

Here's an example:


The above code is saved as a *.bat file. When run in any directory, you can see the short name of the current directory.
Floor6 sunyao Posted 2006-11-30 02:28
初级用户 Posts 60 Credits 141 From 天津
Thanks ccwan
Got it
Floor7 xuzhenhui Posted 2007-01-13 03:53
初级用户 Posts 10 Credits 22
Please clarify the specific context of these symbols in the batch processing you mentioned. Different symbols may have different specific uses in batch commands. For example, the caret (^) is often used as an escape character, the exclamation mark (!) may be related to delayed expansion in certain scenarios, the minus sign (-) may be used in range expressions, and the tilde (~) may have specific meanings in parameter substitution, etc. But without more detailed context, it's difficult to give an extremely accurate and detailed explanation.
Floor8 lxmxn Posted 2007-01-13 03:56
版主 Posts 4,938 Credits 11,386
Originally posted by xuzhenhui at 2007-1-12 14:53:
May I ask you all about the functions and usages of special symbols such as "^ ! -1 ~" in batch processing


  DOS Symbol Issues

  Go to the 4th floor of the above post to have a look, which will be helpful to you.


[ Last edited by lxmxn on 2007-1-12 at 02:57 PM ]
Floor9 jwm112377 Posted 2009-06-18 22:43
初级用户 Posts 20 Credits 25
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023