|
yefenghome
初级用户
 
积分 54
发帖 18
注册 2006-8-26
状态 离线
|
『楼 主』:
求助,在最后一个盘符建一个文件夹
使用 LLM 解释/回答一下
机器的不同,分区不一样,怎么才能在最后一个分区建一个目录。
Different machines have different partitions. How can I create a directory in the last partition?
|
|
2006-9-23 07:03 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
楼主什么好的实现想法吗?
为了兼容纯DOS和WINDOWS下的DOS,for枚举所有驱动器找到最后一个可写的驱动器?为了兼容纯DOS环境不能用VbScript等外部解释型脚本,只能用DOS内部命令。
1、DOS内部命令for枚举所有驱动器盘符
2、if测试枚举出来的盘符是否存在
3、如果存在就在那个盘符上建立你预定的目录名
我帮你做完了,不过最希望你自己做着玩,这样DOS水平提高很快~:)
希望楼主贴上你的实现过程,琢磨它是一件非常好玩的事情~:)
for的枚举与应用方法可以参考看这篇贴子:
==================================
批处理删除所有分区的默认共享
http://www.cn-dos.net/forum/viewthread.php?tid=21133&fpage=4
==================================
if的应用看一下 IF /? 的提示与帮助~:)
知识都是在遇解决不了问题的时候产生突破的~:)
希望楼主尽快做出来~:)
等待楼主讲讲发现和学习感受与精彩片断让大家一起分享~:)
Does the thread starter have any good implementation ideas?
To be compatible with pure DOS and DOS under Windows, use a for loop to enumerate all drives and find the last writable drive? To be compatible with the pure DOS environment, external interpreted scripts like VbScript cannot be used, only DOS internal commands can be used.
1. Enumerate all drive letters using the DOS internal command for
2. Test if the enumerated drive letter exists using if
3. If it exists, create the predetermined directory name on that drive letter
I've done it for you, but I most hope you do it for fun, and then your DOS skills will improve quickly~ : )
Hope the thread starter posts your implementation process. It's a very fun thing to figure it out~ : )
You can refer to this post for the enumeration and application methods of for:
=============================================
Batch script to delete all partition default shares
http://www.cn-dos.net/forum/viewthread.php?tid=21133&fpage=4
=============================================
Take a look at the application of if. Look at the prompt and help of IF /? ~ : )
Knowledge all comes to breakthroughs when encountering unsolvable problems~ : )
Hope the thread starter makes it soon~ : )
Wait for the thread starter to talk about the discovery and learning feelings and wonderful fragments to share with everyone~ : )
|
|
2006-9-24 04:38 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
可以用这个试试:
@echo off
setlocal enabledelayedexpansion
for /f "delims=\" %%i in ('fsutil fsinfo drives^|find /v ""') do (
set var=%%i
set drives=!var:~-2!
md !drives!\lxmxn
)
上面倒数第三行的“lxmxn”是我自己定义的文件夹名,你可以自行更改成你想命名的目录。
You can try this:
@echo off
setlocal enabledelayedexpansion
for /f "delims=\" %%i in ('fsutil fsinfo drives^|find /v ""') do (
set var=%%i
set drives=!var:~-2!
md !drives!\lxmxn
)
The "lxmxn" in the third last line above is the folder name I defined myself, and you can change it to the directory name you want to name by yourself.
|
|
2006-9-25 04:36 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
”求助,在最后一个盘符建一个文件夹“
执行完后,发现它建lxmxn目录到C盘上去了:)
非常佩服Lxmxn兄的fsutil fsinfo drives应用,所有驱动器一下子全出来了,超级爽~:)
"Help, create a folder in the last drive letter"
After execution, I found that it created the lxmxn directory on the C drive : )
I really admire Brother Lxmxn's use of fsutil fsinfo drives, all the drives came out at once, super cool : )
|
|
2006-9-26 03:53 |
|
|
uime
初级用户
 
积分 70
发帖 27
注册 2006-9-19 来自 河南
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
大家是不是没有考虑到最后一个盘符是光盘怎么办?
3楼的结果
E:\>for /F "delims=\" %i in ('fsutil fsinfo drives|find /v ""') do (
set var=%i
set drives=!var:~-2!
md !drives!\lxmxn
)
find: invalid predicate `'
Last edited by uime on 2006-9-26 at 05:37 ]
Is everyone not considering what if the last drive letter is for a CD - ROM?
Result of floor 3
E:\>for /F "delims=\" %i in ('fsutil fsinfo drives|find /v ""') do (
set var=%i
set drives=!var:~-2!
md !drives!\lxmxn
)
find: invalid predicate `'
Last edited by uime on 2006-9-26 at 05:37 ]
|
|
2006-9-26 05:19 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
一直等着楼主提问后看到2楼和3楼的启发自己写出来,
别人都写出来和自己写的来的记忆和懂的内容都不一样,
结果楼主失踪了……
让盘符倒着来,第一个测试的可写的驱动器就一定是最后一个可写的盘符。
@ECHO off
FOR %%c in (Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C) do (
IF exist %%c: (
MD %%c:\Redtek
GOTO :EOF
)
)
I've been waiting for the楼主 to ask a question and then saw the inspiration from the 2nd and 3rd floors to write it myself. The memory and understanding of what others wrote and what I wrote are different. As a result, the楼主 disappeared...
Make the drive letters go in reverse order, and the first writable drive tested will definitely be the last writable drive letter.
@ECHO off
FOR %%c in (Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C) do (
IF exist %%c: (
MD %%c:\Redtek
GOTO :EOF
)
)
|
|
2006-9-26 06:20 |
|
|
uime
初级用户
 
积分 70
发帖 27
注册 2006-9-19 来自 河南
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
Originally posted by redtek at 2006-9-26 06:20:
一直等着楼主提问后看到2楼和3楼的启发自己写出来,
别人都写出来和自己写的来的记忆和懂的内容都不一样,
结果楼主失踪了……
让盘符堮..
如果光驱中有光盘,这个不会执行
如果有用subst虚拟的盘,这个会建在虚拟目录中
Last edited by uime on 2006-9-26 at 19:18 ]
Originally posted by redtek at 2006-9-26 06:20:
Been waiting for the LZ to ask a question, then see the inspiration from floor 2 and 3 to write it out myself.
The memory and understanding of what others have written out versus what I write out are different.
In the end, the LZ disappeared...
Let the drive letter be...
If there is a CD in the optical drive, this will not execute.
If there is a substituted virtual drive, this will be created in the virtual directory.
Last edited by uime on 2006-9-26 at 19:18 ]
|
|
2006-9-26 18:54 |
|
|
yefenghome
初级用户
 
积分 54
发帖 18
注册 2006-8-26
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
Originally posted by redtek at 2006-9-26 06:20:
一直等着楼主提问后看到2楼和3楼的启发自己写出来,
别人都写出来和自己写的来的记忆和懂的内容都不一样,
结果楼主失踪了……
让盘符堮..
初学,看了一下帮助,有一点不明
goto :eof
是什么意思? goto :eof好像是跳到标签为:eof 处执行,可在整个处理中没有发现这个标签。
Originally posted by redtek at 2006-9-26 06:20:
Been waiting for the original poster to ask a question and then see the inspiration from floors 2 and 3 to write it out myself,
The memory and understanding of content written by others and what I write are different,
As a result, the original poster disappeared...
Let the drive letter be...
Just starting to learn, looked at the help, and there is something unclear
What does goto :eof mean? goto :eof seems to be jumping to the label :eof to execute, but this label is not found in the entire processing.
|
|
2006-9-27 05:22 |
|
|
yefenghome
初级用户
 
积分 54
发帖 18
注册 2006-8-26
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
Originally posted by redtek at 2006-9-26 06:20:
一直等着楼主提问后看到2楼和3楼的启发自己写出来,
别人都写出来和自己写的来的记忆和懂的内容都不一样,
结果楼主失踪了……
让盘符堮..
初学,看了一下帮助,有一点不明
goto :eof
是什么意思? goto :eof好像是跳到标签为:eof 处执行,可在整个处理中没有发现这个标签。
Originally posted by redtek at 2006-9-26 06:20:
Been waiting for the original poster to ask a question and then see the inspiration from floors 2 and 3 to write it out myself,
The memory and understanding of what others have written out versus what I write out are different,
As a result, the original poster disappeared...
Let the drive letter...
Just starting to learn, looked at the help, there is something unclear
goto :eof
What does it mean? goto :eof seems to be jumping to the label :eof to execute, but I didn't find this label in the entire process.
|
|
2006-9-27 05:22 |
|
|
chujiafu
银牌会员
    
积分 1337
发帖 594
注册 2004-5-26 来自 安徽 宿州
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
如果在纯Dos中的最后一个盘符是Ram盘怎么办?
What if the last drive letter in pure DOS is a RAM drive?
|
|
2006-9-28 04:09 |
|
|
redtek
金牌会员
     
积分 2902
发帖 1147
注册 2006-9-21
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
如果正在建目录的时候突然停电了怎么办?
如果最后一个盘正巧遇上了被映射的网络上另一台主机的磁盘怎么办?
如果有常驻内存的某个程序监视系统不让向最后一个盘写内容怎么办?
如果最后一个盘是U盘又开启了写保护怎么办?
如果操作的时候遇到了系统百年不遇的BUG怎么办?
哈哈哈……
What if the power is suddenly cut off when the directory is being built?
What if the last disk happens to be a disk of another host on the mapped network?
What if there is a program in memory resident monitoring the system and not allowing writing to the last disk?
What if the last disk is a USB flash drive and write protection is enabled?
What if a once - in - a - hundred - year system bug is encountered during the operation?
Hahaha...
|
|
2006-9-28 06:19 |
|
|
weilong888
银牌会员
    
积分 1270
发帖 548
注册 2004-5-31
状态 离线
|
|
2006-9-28 08:09 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
Originally posted by redtek at 2006-9-26 06:20:
@REM 其中redtek这个名字为你想要建立的目录名称
@REM CreateFile.Bat:
@REM ==========================================
@ECHO off
FOR %%c in (Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C) do (
IF exist %%c: (
MD %%c:\Redtek
GOTO :EOF
)
)
这段代码是有问题的,如果最后一个存在的盘符是光驱的盘符,那么,它就无法创建了。按照楼主的说法,应该是找最后一个可写的盘。那么,就应该写成
@ECHO off
FOR %%c in (Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C) do (
IF exist %%c: (
MD %%c:\Redtek 2>nul && GOTO :EOF
)
)
Originally posted by redtek at 2006-9-26 06:20:
@REM The name redtek is the directory name you want to create
@REM CreateFile.Bat:
@REM ==========================================
@ECHO off
FOR %%c in (Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C) do (
IF exist %%c: (
MD %%c:\Redtek
GOTO :EOF
)
)
There is a problem with this code. If the last existing drive letter is that of a CD-ROM drive, then it won't be able to create it. According to the original poster's statement, it should be finding the last writable drive. Then it should be written as
@ECHO off
FOR %%c in (Z,Y,X,W,V,U,T,S,R,Q,P,O,N,M,L,K,J,I,H,G,F,E,D,C) do (
IF exist %%c: (
MD %%c:\Redtek 2>nul && GOTO :EOF
)
)
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-9-28 10:33 |
|
|
Jnwei1202
初级用户
 
积分 197
发帖 33
注册 2003-7-24
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
这上面所说的只能在 FAT16 FAT32 的分区格式上吧
在纯DOS下如果是 硬盘全是NTFS 格式或最后一个盘是NTFS格式就不行了
Last edited by Jnwei1202 on 2006-9-28 at 21:36 ]
What is said above can only be on the partition formats of FAT16 FAT32. In pure DOS, if the hard disk is all in NTFS format or the last partition is in NTFS format, it won't work.
Last edited by Jnwei1202 on 2006-9-28 at 21:36 ]
|
|
2006-9-28 21:28 |
|
|
NaturalJ0
银牌会员
    
积分 1181
发帖 533
注册 2006-8-14
状态 离线
|
|
2006-9-28 22:04 |
|
|