|
zhamin
新手上路

积分 6
发帖 1
注册 2006-3-5
状态 离线
|
『楼 主』:
在DOS下,如何确定硬盘的最后一个分区的盘符;如何判定目
使用 LLM 解释/回答一下
在只有一个光驱的情况下,用FINDCD可以确定光驱的驱动器号,如何根据这个驱动器号来确定硬盘最后一个分区的盘符(不含NTFS分区)。想建目录名时,以及如何判定目录名是否存在?请高手作答。
Under the condition of having only one CD-ROM drive, FINDCD can be used to determine the drive letter of the CD-ROM drive. How to determine the drive letter of the last partition of the hard disk (excluding NTFS partitions) according to this drive letter? When creating a directory name, and how to determine whether the directory name exists? Please experts answer.
|
|
2006-3-5 23:50 |
|
|
lks205
初级用户
 
积分 86
发帖 32
注册 2006-1-27
状态 离线
|
|
2006-3-11 11:00 |
|
|
baomaboy
银牌会员
    
积分 1513
发帖 554
注册 2005-12-30
状态 离线
|
|
2006-3-11 12:58 |
|
|
chenall
银牌会员
    
积分 1276
发帖 469
注册 2002-12-23 来自 福建泉州
状态 离线
|
|
2006-3-11 16:28 |
|
|
kpc163
初级用户
 
积分 22
发帖 9
注册 2006-3-1
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
『第 5 楼』:
OK,刚才给FINDCD增加了一个选项/L,用于显示和设置第一个光驱前的盘符给%CDROM%,试试看吧:
打开附件
例如,假设光驱为D:
FINDCD /L
CDROM=C:
附件下载不了
『Post #5』:
OK, just now I added an option /L to FINDCD to display and set the drive letter before the first CD-ROM to %CDROM%. Let's give it a try:
Open the attachment
For example, suppose the CD-ROM is D:
FINDCD /L
CDROM=C:
Attachment cannot be downloaded
|
|
2006-3-11 23:08 |
|
|
floor
初级用户
 
积分 185
发帖 82
注册 2005-8-12
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
使用下面方法
func -a6>list.txt // 将所有分区盘符写入list.txt(不包括光驱)
STRINGS a=LINESIZE list.txt //返回文件内容的总行数
STRINGS p=READ list.txt,%a% //读取文件中指定行数的内容
echo %p% //%p%就是最后分区的盘符
Use the following method
func -a6>list.txt // Write all partition drive letters to list.txt (excluding CD-ROM drives)
STRINGS a=LINESIZE list.txt // Return the total number of lines in the file content
STRINGS p=READ list.txt,%a% // Read the content of the specified line in the file
echo %p% // %p% is the drive letter of the last partition
|
|
2006-3-12 01:21 |
|
|
chenall
银牌会员
    
积分 1276
发帖 469
注册 2002-12-23 来自 福建泉州
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
还有一个方法,可以试试
使用MD
if exist在判断最后一个分区的盘符.
可以试试以下方法.
@echo off
set drv=c d e f g h i j k l m n o p q r s t u v w x y z
if "%1"=="" if "%last_drv%"=="" call %0 %drv%
:set_last
if "%1"=="" goto end
md %1:\last.drv>nul
if not exist %1:\last.drv\nul goto end
rd %1:\last.drv>nul
set last_drv=%1:
shift
goto set_last
:end
There is another method, you can try.
Use MD
if exist to judge the drive letter of the last partition.
You can try the following method.
@echo off
set drv=c d e f g h i j k l m n o p q r s t u v w x y z
if "%1"=="" if "%last_drv%"=="" call %0 %drv%
:set_last
if "%1"=="" goto end
md %1:\last.drv>nul
if not exist %1:\last.drv\nul goto end
rd %1:\last.drv>nul
set last_drv=%1:
shift
goto set_last
:end
|

QQ:366840202
http://chenall.net |
|
2006-3-12 12:31 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
看起来都挺牛b的,咱也来一个:
@echo off
cd\
set c=C:
set d=D:
set e=E:
set f=F:
set g=G:
set h=H:
set i=I:
set j=J:
set k=K:
set l=L:
set m=M:
set n=N:
set o=O:
set p=P:
set q=Q:
set r=R:
set s=S:
set t=T:
set u=U:
set v=V:
set w=W:
set x=X:
set y=Y:
set z=Z:
%c%
%d%
%E%
%f%
%g%
%h%
%i%
%j%
%k%
%l%
%m%
%n%
%o%
%p%
%q%
%r%
%s%
%t%
%u%
%v%
%w%
%x%
%y%
%z%
if "%cd%" == "%d%\" %c%
if "%cd%" == "%e%\" %d%
if "%cd%" == "%f%\" %e%
if "%cd%" == "%g%\" %f%
if "%cd%" == "%h%\" %g%
if "%cd%" == "%i%\" %h%
if "%cd%" == "%j%\" %i%
if "%cd%" == "%k%\" %j%
if "%cd%" == "%l%\" %k%
if "%cd%" == "%m%\" %l%
if "%cd%" == "%n%\" %m%
if "%cd%" == "%o%\" %n%
if "%cd%" == "%p%\" %o%
if "%cd%" == "%q%\" %p%
if "%cd%" == "%r%\" %q%
if "%cd%" == "%s%\" %r%
if "%cd%" == "%t%\" %s%
if "%cd%" == "%u%\" %t%
if "%cd%" == "%v%\" %u%
if "%cd%" == "%w%\" %v%
if "%cd%" == "%x%\" %w%
if "%cd%" == "%y%\" %x%
if "%cd%" == "%z%\" %y%
在命令行中测试通过,假设光驱内有盘,且可以在命令行中访问。
之所以写这么长是为了方便在DOS下执行,不知道DOS下有没有%cd%这个环境变量,无聊的朋友帮忙在DOS下测试下看看,注意语句中的大小写。
Last edited by 3742668 on 2006-3-12 at 22:49 ]
It all looks quite impressive. Let's do one too:
@echo off
cd\
set c=C:
set d=D:
set e=E:
set f=F:
set g=G:
set h=H:
set i=I:
set j=J:
set k=K:
set l=L:
set m=M:
set n=N:
set o=O:
set p=P:
set q=Q:
set r=R:
set s=S:
set t=T:
set u=U:
set v=V:
set w=W:
set x=X:
set y=Y:
set z=Z:
%c%
%d%
%E%
%f%
%g%
%h%
%i%
%j%
%k%
%l%
%m%
%n%
%o%
%p%
%q%
%r%
%s%
%t%
%u%
%v%
%w%
%x%
%y%
%z%
if "%cd%" == "%d%\" %c%
if "%cd%" == "%e%\" %d%
if "%cd%" == "%f%\" %e%
if "%cd%" == "%g%\" %f%
if "%cd%" == "%h%\" %g%
if "%cd%" == "%i%\" %h%
if "%cd%" == "%j%\" %i%
if "%cd%" == "%k%\" %j%
if "%cd%" == "%l%\" %k%
if "%cd%" == "%m%\" %l%
if "%cd%" == "%n%\" %m%
if "%cd%" == "%o%\" %n%
if "%cd%" == "%p%\" %o%
if "%cd%" == "%q%\" %p%
if "%cd%" == "%r%\" %q%
if "%cd%" == "%s%\" %r%
if "%cd%" == "%t%\" %s%
if "%cd%" == "%u%\" %t%
if "%cd%" == "%v%\" %u%
if "%cd%" == "%w%\" %v%
if "%cd%" == "%x%\" %w%
if "%cd%" == "%y%\" %x%
if "%cd%" == "%z%\" %y%
Tested in the command line and it works. Assume there's a disk in the CD-ROM and it can be accessed in the command line. The reason for writing it so long is to make it easy to execute under DOS. Not sure if there's the %cd% environment variable under DOS. Bored friends, help test it under DOS and pay attention to the case of the statements.
Last edited by 3742668 on 2006-3-12 at 22:49 ]
|
|
2006-3-12 21:09 |
|
|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
如果系统启动时设置了内存虚拟盘,那么以上所有的程序都会失效。
If the system is set with a memory virtual disk during startup, then all the above programs will become invalid.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2006-3-13 00:31 |
|
|
lks205
初级用户
 
积分 86
发帖 32
注册 2006-1-27
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
Originally posted by Climbing at 2006-3-13 00:31:
如果系统启动时设置了内存虚拟盘,那么以上所有的程序都会失效。
那岂不是一切又都白做了,空欢喜一场!
Originally posted by Climbing at 2006-3-13 00:31, Climbing **Content**: If the system sets up a memory virtual disk during startup, all the above programs will become invalid.
Then it's all in vain, a false alarm!
Originally posted by Climbing at 2006-3-13 00:31:
If the system sets up a memory virtual disk during startup, all the above programs will become invalid.
Then it's all in vain, a false alarm!
|
|
2006-3-13 13:46 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
哈哈,楼上这两位真是搞笑。
如果你能提供一个完美的方案出来我才会觉得你牛b
要不就一边呆着去。
Haha, the two upstairs are really funny.
I will only think you are awesome if you can provide a perfect solution.
Otherwise, just go stay aside.
|
|
2006-3-13 20:09 |
|
|
floor
初级用户
 
积分 185
发帖 82
注册 2005-8-12
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
Originally posted by Climbing at 2006-3-13 00:31:
如果系统启动时设置了内存虚拟盘,那么以上所有的程序都会失效。
设置了虚拟内存盘也没关系,因为strings返回文件总行数总是比实际行数少一行,而用 "strings read file,返回的总行数" 得到的是倒数第二行的内容,正好是这个问题想要的答案。至于为什么用它返回的总行数读的不是最后一行我也没搞清呵呵。
func -a6 输出格式:
C
D
E
.
.
.
X :: X为虚拟内存盘符
Originally posted by Climbing at 2006-3-13 00:31:
If the system sets up a memory virtual disk during startup, then all the above programs will become invalid.
It's okay if the virtual memory disk is set up, because the total number of lines returned by strings is always one less than the actual number of lines, and the total number of lines obtained by "strings read file" returns the content of the second-to-last line, which is exactly the answer this question wants. As for why the last line is not read with the total number of lines it returns, I haven't figured it out yet, heh heh.
Output format of func -a6:
C
D
E
.
.
.
X :: X is the virtual memory disk letter
|
|
2006-3-14 02:01 |
|