|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
你试试md a.b这个命令,就知道x不是多余的了,这也是程序严密性的体现。没有跟你争论的意思,只是提醒你要注意严密性,搞技术的一定要注意这一点。
You try the command "md a.b", and you'll know that x is not redundant. This is also an embodiment of the program's strictness. I'm not arguing with you, just reminding you to pay attention to strictness. Those in technology must pay attention to this point.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2004-11-10 00:00 |
|
|
GOTOmsdos
铂金会员
       C++启程者
积分 5154
发帖 1827
注册 2003-7-18
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
我试过了,对带点的目录名,没有问题,我试了A.B.F这样的目录,都没问题,说明这个x确是管文件的扩展名的,而不是带点的目录名.因为我们的批处理的/d已经确定它是目录了..这个X就不起作用了
I tried it. For directory names with dots, there's no problem. I tested directories like A.B.F, and they all worked fine. This shows that X indeed controls the file extension, not directory names with dots. Because our batch processing's /d has already determined it's a directory.. Then X doesn't work.
|
|
2004-11-10 00:00 |
|
|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
在我的试验中,如果不带x就不行的,假如C:盘中a目录,如果不带x,就会将D:盘的a.1 a.2等目录删除。
In my experiment, it won't work without x. For example, in directory a on drive C:; if you don't have x, it will delete directories like a.1, a.2, etc., on drive D:.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2004-11-10 00:00 |
|
|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
@echo off
:: testfor.bat 测试for命令及命令扩展
:: 功能:删除2目录下所有与1目录中重名的子目录
rd /s /q 1
rd /s /q 2
md 1\a
md 1\a.1
md 1\b
md 1\c
md 2\a
md 2\a.1
md 2\a.2
md 2\b
md 2\c
md 2\d
md 2\e
echo ================================================================
echo 目录 1 的内容:
echo ================================================================
dir /b 1
echo ================================================================
echo 目录 2 的内容:
echo ================================================================
dir /b 2
echo ================================================================
echo 运行第一个for命令之后(if %%~ni==%%~nj),目录2的内容变为:
for /d /r 1 %%i in (*) do for /d /r 2 %%j in (*) do if %%~ni==%%~nj rd /s /q %%j
echo ================================================================
dir /b 2
echo ================================================================
echo 注意:a.2目录被错误的删除了。
pause
echo.
echo ================================================================
echo 准备运行第二个for命令...
echo ================================================================
rd /s /q 1
rd /s /q 2
md 1\a
md 1\a.1
md 1\b
md 1\c
md 2\a
md 2\a.1
md 2\a.2
md 2\b
md 2\c
md 2\d
md 2\e
echo 目录 1 的内容:
echo ================================================================
dir /b 1
echo ================================================================
echo 目录 2 的内容:
echo ================================================================
dir /b 2
echo ================================================================
echo 运行第二个for命令之后(if %%~nxi==%%~nxj),目录2的内容变为:
for /d /r 1 %%i in (*) do for /d /r 2 %%j in (*) do if %%~nxi==%%~nxj rd /s /q %%j
echo ================================================================
dir /b 2
echo ================================================================
echo 看,a.2目录没有被删除。
echo.
echo ================================================================
echo 测试结果:目录名同样是有扩展名的。
@echo off
:: testfor.bat Test for command and command extensions
:: Function: Delete all subdirectories in directory 2 that have the same name as those in directory 1
rd /s /q 1
rd /s /q 2
md 1\a
md 1\a.1
md 1\b
md 1\c
md 2\a
md 2\a.1
md 2\a.2
md 2\b
md 2\c
md 2\d
md 2\e
echo ================================================================
echo Contents of directory 1:
echo ================================================================
dir /b 1
echo ================================================================
echo Contents of directory 2:
echo ================================================================
dir /b 2
echo ================================================================
echo After running the first for command (if %%~ni==%%~nj), the contents of directory 2 become:
for /d /r 1 %%i in (*) do for /d /r 2 %%j in (*) do if %%~ni==%%~nj rd /s /q %%j
echo ================================================================
dir /b 2
echo ================================================================
echo Note: The a.2 directory was mistakenly deleted.
pause
echo.
echo ================================================================
echo Preparing to run the second for command...
echo ================================================================
rd /s /q 1
rd /s /q 2
md 1\a
md 1\a.1
md 1\b
md 1\c
md 2\a
md 2\a.1
md 2\a.2
md 2\b
md 2\c
md 2\d
md 2\e
echo Contents of directory 1:
echo ================================================================
dir /b 1
echo ================================================================
echo Contents of directory 2:
echo ================================================================
dir /b 2
echo ================================================================
echo After running the second for command (if %%~nxi==%%~nxj), the contents of directory 2 become:
for /d /r 1 %%i in (*) do for /d /r 2 %%j in (*) do if %%~nxi==%%~nxj rd /s /q %%j
echo ================================================================
dir /b 2
echo ================================================================
echo Look, the a.2 directory was not deleted.
echo.
echo ================================================================
echo Test result: The directory name also has an extension.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2004-11-10 00:00 |
|
|
GOTOmsdos
铂金会员
       C++启程者
积分 5154
发帖 1827
注册 2003-7-18
状态 离线
|
『第 20 楼』:
使用 LLM 解释/回答一下
哦,我刚才没明白你的意思,又试了,确实如你所说,现在发现FOR命令 的解释(或者程序)本身有问题,它说是处理扩展名,其实是处理所有带点的(包括目录),我还发现,这个X解析带点的,只以最后一个点为界。有点的话,如果不加X,它就分析最后的点之前的全部,如果加X,就分析全部。所以,如果有多点,并且不加X,比如A.B.C,他也不会认为和A相同.总之,这是一个缺陷,完整的处理是:对目录一律包括点,处理目录应该当作一个整体,只有当分析文件时才分扩展.
Oh, I didn't understand your meaning just now. I tried again, and it's indeed as you said. Now I find that there's a problem with the explanation (or program) of the FOR command. It says it handles extensions, but actually it handles all that have dots (including directories). I also found that this X parses the ones with dots, only taking the last dot as the boundary. If there's a dot and you don't add X, it will analyze all before the last dot; if you add X, it will analyze all. So, if there are multiple dots and you don't add X, for example, A.B.C, it won't think it's the same as A. In short, this is a defect. The complete handling is: directories are all included with dots, directories should be treated as a whole, and only when analyzing files are extensions separated.
|
|
2004-11-10 00:00 |
|
|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
无论是Windows还是Linux系统,文件和目录的命名规则都是一样的,处理方式也是相同的,所以这不是系统的缺陷,只是你的程序考虑的不够严密罢了。
Whether it's Windows or Linux systems, the naming rules for files and directories are the same, and the handling methods are also identical. So this is not a defect of the system, but simply that your program hasn't been considered carefully enough.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2004-11-11 00:00 |
|
|
qzwqzw
银牌会员
     天的白色影子
积分 2343
发帖 636
注册 2004-3-6
状态 离线
|
『第 22 楼』:
使用 LLM 解释/回答一下
Oh, Hit!!! 为了回复这个问题当机三次,想当个高手咋就这么难呢?dos我懂得不多,只记得学过一句,似乎跟这有些关系: for %%f in (d:\program\*.*) do if exist c:\%%f del c:\%%f不过用在这里好像不太行哦,是我的脑袋太笨,还是楼主的问题有问题?我总觉得,为什么不直接用dir看一下在哪,然后用deltree或者rd /s删除呢?怕删错还可以逐步确认呀。为什么一定要用那么长的for命令,还有那复杂的批处理?难道楼主你会一遍又一遍的把软件装错地方?有简单的不用,用复杂的,是一种罪过哦。所以,我到现在一直是用"查找"找到它,然后选中delete,方便快捷,没有后遗症。
Oh, Hit!!! I crashed three times in order to reply to this question. Why is it so hard to be a master? I don't know much about DOS. I just remember learning a sentence that seems related to this: for %%f in (d:\program\*.*) do if exist c:\%%f del c:\%%f But it doesn't seem to work here. Is my head too stupid or is the owner's question wrong? I always think, why not just use dir to see where it is, and then use deltree or rd /s to delete? You can gradually confirm if you are afraid of deleting by mistake. Why must you use such a long for command and such a complicated batch processing? Do you, the owner, install the software in the wrong place over and over again? Using a simple one when there is a simple one available and using a complicated one is a sin. So, I have been using "Find" to find it, then select delete, which is convenient and fast, with no aftereffects.
|
|
2004-11-11 00:00 |
|
|
tired_bird
中级用户
  
积分 307
发帖 58
注册 2004-10-21
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
看了这份贴,加深了for 语句的用法及功能的理解。同时从Climbing和GOTOmsdos身上学到很多东西,受益匪浅。不过好像Climbing关于“无论是Windows还是Linux系统,文件和目录的命名规则都是一样的,处理方式也是相同的”的说法我有点不同看法,linux下文件和目录的命名规则可以支持冒号:,而xp 下及cygwin中的bash中文件和目录的命名不支持冒号。
After reading this post, I have deepened my understanding of the usage and functions of the for statement. At the same time, I have learned a lot from Climbing and GOTOmsdos and benefited a lot. However, I have a different opinion on Climbing's statement that "whether it is the Windows or Linux system, the naming rules for files and directories are the same, and the processing methods are also the same". The naming rules for files and directories under Linux can support colons :, while the naming of files and directories under XP and in the bash of cygwin does not support colons.
|
|
2004-11-11 00:00 |
|
|
insert
中级用户
  
积分 282
发帖 52
注册 2004-9-29
状态 离线
|
『第 24 楼』:
使用 LLM 解释/回答一下
同意22楼的说法,又不是每次都会解错地方,干吗要弄得那么复杂啊!!又没实际作用。
Agree with the statement of building 22. It's not that every time you will misplace it. Why make it so complicated? It has no practical use.
|
|
2004-11-11 00:00 |
|
|
GOTOmsdos
铂金会员
       C++启程者
积分 5154
发帖 1827
注册 2003-7-18
状态 离线
|
『第 25 楼』:
使用 LLM 解释/回答一下
to qzwqzw你没看清我的要求,我要求之一是:就因为文件太多了,一个个的看,找,太麻烦啊! 所以用DIR是肯定不行的!for %%f in (d:\program\*.*) do if exist c:\%%f del c:\%%f你的以上方法可以精简成我的帖子中的答案。后面的要求再看后面的内容。。。
to qzwqzwYou didn't see my requirement clearly. One of my requirements is: Just because there are too many files, it's too troublesome to look at and find them one by one! So using DIR is definitely not okay! for %%f in (d:\program\*.*) do if exist c:\%%f del c:\%%fYour above method can be streamlined into the answer in my post. Let's look at the following content for the subsequent requirements...
|
|
2004-11-11 00:00 |
|
|
GOTOmsdos
铂金会员
       C++启程者
积分 5154
发帖 1827
注册 2003-7-18
状态 离线
|
『第 26 楼』:
使用 LLM 解释/回答一下
TO insert 当然不是每个DOS技术都是很常用的,但对于学习研究DOS者来说,这就是钻研的任务之一。但一旦你或你的朋友遇到类似情况,就会显示出DOS功底的力量了。。
OF course, not every DOS technique is very common, but for those who study and research DOS, this is one of the tasks of delving in. But once you or your friends encounter a similar situation, the power of DOS skills will be demonstrated..
|
|
2004-11-11 00:00 |
|
|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 27 楼』:
使用 LLM 解释/回答一下
以下是引用tired_bird在2004-11-11 21:00:11的发言:
看了这份贴,加深了for 语句的用法及功能的理解。同时从Climbing和GOTOmsdos身上学到很多东西,受益匪浅。
不过好像Climbing关于“无论是Windows还是Linux系统,文件和目录的命名规则都是一样的,处理方式也是相同的”的说法我有点不同看法,linux下文件和目录的命名规则可以支持冒号:,而xp 下及cygwin中的bash中文件和目录的命名不支持冒号。
我并不是说Windows 和 Linux的文件命名规则是一样的(Windows下当然会有很多限制),但在同一个系统下,文件和目录名的命名规则是一样的。
The following is the speech of tired_bird on November 11, 2004 at 21:00:11:
After reading this post, I have deepened my understanding of the usage and function of the for statement. At the same time, I have learned a lot from Climbing and GOTOmsdos and benefited a lot.
However, I have a slightly different view on Climbing's statement that "whether it is the Windows or Linux system, the naming rules for files and directories are the same, and the processing methods are also the same". In the Linux system, the naming rules for files and directories can support colons :, while in the XP system and the bash in cygwin, the naming of files and directories does not support colons.
I'm not saying that the file naming rules of Windows and Linux are the same (of course there are many restrictions under Windows), but within the same system, the naming rules of file and directory names are the same.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2004-11-12 00:00 |
|
|
bush
银牌会员
    
积分 2165
发帖 730
注册 2004-4-21
状态 离线
|
『第 28 楼』:
使用 LLM 解释/回答一下
樓主說的:D:\PROGRAM>for %1 in (*) do del c:\%1 /s 不好。你必须保证你的压缩文件中的一级目录在C盘也是唯一的。壓縮文件中的一級目錄在c盤中必須唯一,且沒有其他同名文件。還是先定位好。
The LZ said: D:\PROGRAM>for %1 in (*) do del c:\%1 /s is not good. You must ensure that the first-level directory in your compressed file is unique on the C drive. The first-level directory in the compressed file must be unique on the C drive and there are no other files with the same name. It's still better to locate it first.
|
|
2004-11-12 00:00 |
|
|
bush
银牌会员
    
积分 2165
发帖 730
注册 2004-4-21
状态 离线
|
『第 29 楼』:
使用 LLM 解释/回答一下
其實,dir/d 按時閒排序,再刪除解壓時節以後的文件即可,雖然多一個步驟但是可靠一些.
Actually, sorting by time with `dir /d` and then deleting files created after decompression is okay. Although it's one more step, it's more reliable.
|
|
2004-11-12 00:00 |
|
|
GOTOmsdos
铂金会员
       C++启程者
积分 5154
发帖 1827
注册 2003-7-18
状态 离线
|
『第 30 楼』:
使用 LLM 解释/回答一下
to bush
没错,必须确定C盘中其他地方没有同名文件,跟目录没有关系,这句只解决文件呀
我这些考题其实只是从理论上实现达到一种意图,如果真要操作的话,肯定要再加控制其他条件的语句的
to bush
Yes, you must make sure there are no files with the same name elsewhere in drive C. It has nothing to do with the root directory. This sentence only addresses the file.
These exam questions of mine are actually just to achieve an intention theoretically. If you really want to operate, you must definitely add statements to control other conditions.
|
|
2004-11-12 00:00 |
|