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!
Credits 3,946 Posts 1,884 Joined 2006-01-20 13:00 20-year member UID 49283 Gender Male
Status Offline
Tested on a virtual machine, would it be different on a real machine? Let's use a real DOS to see.
Report the test result, the result on the real machine is completely the same as that on the virtual machine. Using the virtual machine is mainly for convenient screenshotting.
[ Last edited by lianjiang2004 on 2006-10-30 at 07:05 AM ]
Credits 11,386 Posts 4,938 Joined 2006-07-23 17:10 19-year member UID 59080
Status Offline
It's not about you testing any virtual machine or DOS real mode. It's that the DOS system doesn't support the execution of symbols like "(" and ")" and "&", so you need to use statements like if and goto for workarounds..
Credits 3,946 Posts 1,884 Joined 2006-01-20 13:00 20-year member UID 49283 Gender Male
Status Offline
I only know a little bit about DOS, usually I just modify others' autoexec.bat and so on. Can you take a look at my problem? How to write it under DOS?
I'm sorry, I didn't make the problem clear at the beginning.
[ Last edited by lianjiang2004 on 2006-10-30 at 07:33 AM ]
Credits 35 Posts 14 Joined 2006-10-16 05:53 19-year member UID 65933
Status Offline
Moderator namejm, I have some doubts about the code you wrote above. It seems that it can only find the first partition containing aaa.txt. Is that correct?
Credits 5,493 Posts 2,315 Joined 2006-05-01 10:41 20-year member UID 54766 Gender Male From 上海
Status Offline
@echo off
for %%a in (c d e f g h i j k l m n o) do if exist %%a:\aaa.txt set 输出盘符变量=%%a
for %%b in (c d e f g h i j k l m n o) do if "%输出盘符变量%"=="%%b" echo aaa.txt位于 %%b:
Credits 3,946 Posts 1,884 Joined 2006-01-20 13:00 20-year member UID 49283 Gender Male
Status Offline
### 这里可能原文本就是这样,按照要求直接呈现翻译后的内容(因为原内容主要是代码相关,这里就是保留原样呈现)
@echo off
for %%a in (c d e f g h i j k l m n o) do if exist %%a:\aaa.txt set 输出盘符变量=%%a
for %%b in (c d e f g h i j k l m n o) do if "%输出盘符变量%"=="%%b" ...
Ask: The for %%a sentence has given the variable the drive letter where aaa.txt exists. What is the function of the for %%b sentence? Can it be omitted?
Credits 5,493 Posts 2,315 Joined 2006-05-01 10:41 20-year member UID 54766 Gender Male From 上海
Status Offline
Dizzy~ All the first sentences can be removed. ^_^
The second sentence: for is to meet your requirements (if it exists, output the drive letter to a variable and perform other tasks; otherwise, continue searching until drive O ends.) You can change echo aaa.txt located in %%b: to goto %%b: or edit %%b:\aaa.txt
Credits 5,226 Posts 1,737 Joined 2006-03-10 00:38 20-year member UID 51697 From 成都
Status Offline
Originally posted by hhl at 2006-10-30 08:05:
Moderator namejm, I have some doubts about the code you wrote above. It seems that it can only find the first partition containing aaa.txt. Is that right?
Completely correct. Because the original poster said that as long as it is found, it will display and perform other actions, so it was written like that. If you want to find all partitions containing aaa.txt, it is actually not difficult.