China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-31 22:27
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Some doubts about the set command (solved) View 9,440 Replies 44
Floor 16 Posted 2007-02-14 09:05 ·  中国 重庆 璧山区 电信
初级用户
Credits 58
Posts 31
Joined 2007-01-06 11:16
19-year member
UID 75621
Gender Male
From 重庆
Status Offline
What the person on the 5th floor said is very clear. Novices like us can understand it at a glance.
Floor 17 Posted 2007-03-13 02:22 ·  中国 江苏 南京 电信
初级用户
Credits 76
Posts 39
Joined 2007-03-09 06:54
19-year member
UID 81169
Gender Male
Status Offline
Well asked, well answered. Well added points, learned a lot...
狐狸喜欢狡猾。。
Floor 18 Posted 2007-03-13 08:21 ·  中国 湖北 武汉 电信
初级用户
Credits 76
Posts 38
Joined 2007-03-13 02:54
19-year member
UID 81544
Gender Male
Status Offline
Floor 19 Posted 2007-03-21 07:23 ·  中国 北京 雅虎中国
中级用户
★★
菜鸟总动员
Credits 259
Posts 112
Joined 2006-08-28 15:53
19-year member
UID 61454
Status Offline
The judgment about file extensions is very helpful for learning. Thanks a lot, senior!
Floor 20 Posted 2007-04-02 08:27 ·  中国 江苏 无锡 电信
初级用户
Credits 24
Posts 11
Joined 2007-03-30 13:56
19-year member
UID 83405
Gender Male
Status Offline
Originally posted by 0401 at 2007-1-20 02:13 PM:
HoHo~ I'm more suitable for answering such basic questions

For question one, you can find out by doing it yourself.
The first sentence originally means to set variable a to empty, so there should be nothing on the right side of the equal sign...


0401 is a good teacher, very patient, worthy of our learning, but some students don't listen carefully in class. Hehe.
Floor 21 Posted 2007-04-02 10:11 ·  中国 安徽 合肥 电信
初级用户
Credits 47
Posts 16
Joined 2007-04-02 09:47
19-year member
UID 83710
Gender Male
Status Offline
How to understand this code? There are many special symbol usages. Please ask everyone! Thank you in advance!
setlocal enabledelayedexpansion
for %%i in ("%tmp%\encrypt.tmp") do (
echo %%~zi >nul 2>nul
set size=%%~zi
set num=!size:~-1!
set /a mod=!num!%%2
if !mod! equ 0 (goto even) else (goto odd)
)
Floor 22 Posted 2007-04-09 05:41 ·  中国 湖北 荆州 电信
新手上路
Credits 6
Posts 3
Joined 2007-04-06 22:27
19-year member
UID 84200
Gender Male
Status Offline
I also learned something, thanks for the explanation
Floor 23 Posted 2007-04-17 07:31 ·  中国 上海 电信
初级用户
Credits 24
Posts 12
Joined 2007-04-13 21:05
19-year member
UID 85038
Gender Male
Status Offline
Learned quite a lot of things~~~~
Floor 24 Posted 2007-04-18 07:48 ·  中国 广东 广州 鹏博士宽带
初级用户
★★
Credits 176
Posts 78
Joined 2007-04-15 10:53
19-year member
UID 85268
Gender Male
Status Offline
Originally posted by myth126 at 2007-4-1 09:11 PM:
How to understand the following code? There are many special symbols used. Please ask everyone! Thank you in advance!
setlocal enabledelayedexpansion
for %%i in ("%tmp%\encrypt.tmp") do (
echo %%~zi >nul 2&g ...

Hope experts can answer. I also don't understand. Probably the third line echo %%~zi >nul 2>nul I don't know what it means.
Floor 25 Posted 2007-04-18 09:37 ·  中国 辽宁 大连 联通
初级用户
Credits 70
Posts 38
Joined 2007-03-24 09:25
19-year member
UID 82762
Gender Male
Status Offline
Originally posted by Vampire at 2007-4-17 06:48 PM:

Hope the experts can answer, I also have some doubts. Probably the third line echo %%~zi >nul 2>nul I don't know what it means.


Probably it means not to display the file size of %i, and also not to display errors.
Floor 26 Posted 2007-04-20 00:14 ·  中国 内蒙古 呼和浩特 联通
新手上路
Credits 13
Posts 7
Joined 2007-03-11 05:02
19-year member
UID 81371
Gender Male
Status Offline
Learned, I've learned some more things
Floor 27 Posted 2007-04-20 00:55 ·  中国 安徽 芜湖 电信
高级用户
★★★
Credits 866
Posts 415
Joined 2005-12-04 11:19
20-year member
UID 46459
Status Offline
Expand variable %%i to the file size. There is an explanation in for /?:

Variables with modifiers Description
%~I Expand %I with any quotes ("") around it removed.
%~fI Expand %I to the fully qualified pathname.
%~dI Expand %I to just the drive letter.
%~pI Expand %I to just the path.
%~nI Expand %I to just the file name.
%~xI Expand %I to just the file extension.
%~sI Expand the path to contain only the short name.
%~aI Expand %I to the file's file attributes.
%~tI Expand %I to the file's date and time.
%~zI Expand %I to the file size.
%~$PATH:I Search the directories listed in the PATH environment variable and expand %I to the first fully qualified name found. If the environment variable name is not defined or the file is not found during the search, this modifier expands to an empty string.

The following table lists modifier combinations that can be used to obtain composite results.

Variable (using combined modifiers) Description
%~dpI Expand %I to just the drive letter and path.
%~nxI Expand %I to just the file name and extension.
%~fsI Expand %I to the full pathname containing only the short name.
%~dp$PATH:I Search for %I in the directories listed in the PATH environment variable and expand to the drive letter and path of the first found result.
%~ftzaI Expand %I to an output line (like dir).
欢迎你到批处理爱好者联盟QQ群:18023953
Floor 28 Posted 2007-05-02 16:01 ·  中国 云南 昆明 电信
初级用户
Credits 57
Posts 29
Joined 2006-12-27 09:36
19-year member
UID 74694
Gender Male
Status Offline
It is quite suitable for us beginners. But to be honest, there are some places I still don't understand what they mean. Alas! I can only take it slowly. Once again, I especially thank the GG on the first floor. You are really a very enthusiastic netizen. Your spirit is worthy of our learning.
Floor 29 Posted 2007-07-10 22:19 ·  中国 上海 浦东新区 电信
新手上路
Credits 18
Posts 8
Joined 2007-06-24 22:34
19-year member
UID 92265
Gender Male
Status Offline
Just had some understanding of the use of set just now in 5 minutes
Floor 30 Posted 2007-07-11 17:42 ·  中国 湖北 潜江 电信
高级用户
★★★
Credits 894
Posts 411
Joined 2007-02-17 12:15
19-year member
UID 79697
Gender Male
Status Offline
Only when you understand the set command thoroughly can you write good things.
@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul


Forum Jump: