![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-13 12:37 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS学习入门 & 精彩文章 (教学室) » Seek help, create a folder in the last drive letter |
| Printable Version 5,235 / 27 |
| Floor1 yefenghome | Posted 2006-09-23 07:03 |
| 初级用户 Posts 18 Credits 54 | |
|
Different machines have different partitions. How can I create a directory in the last partition?
|
|
| Floor2 redtek | Posted 2006-09-24 04:38 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
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~ : ) |
|
| Floor3 lxmxn | Posted 2006-09-25 04:36 |
| 版主 Posts 4,938 Credits 11,386 | |
|
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. |
|
| Floor4 redtek | Posted 2006-09-26 03:53 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
"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 : ) |
|
| Floor5 uime | Posted 2006-09-26 05:19 |
| 初级用户 Posts 27 Credits 70 From 河南 | |
|
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 ( [ Last edited by uime on 2006-9-26 at 05:37 ] |
|
| Floor6 redtek | Posted 2006-09-26 06:20 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
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. |
|
| Floor7 uime | Posted 2006-09-26 18:54 |
| 初级用户 Posts 27 Credits 70 From 河南 | |
Originally posted by redtek at 2006-9-26 06:20: 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 ] |
|
| Floor8 yefenghome | Posted 2006-09-27 05:22 |
| 初级用户 Posts 18 Credits 54 | |
Originally posted by redtek at 2006-9-26 06:20: 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. |
|
| Floor9 yefenghome | Posted 2006-09-27 05:22 |
| 初级用户 Posts 18 Credits 54 | |
Originally posted by redtek at 2006-9-26 06:20: 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. |
|
| Floor10 chujiafu | Posted 2006-09-28 04:09 |
| 银牌会员 Posts 595 Credits 1,339 From 安徽 宿州 | |
|
What if the last drive letter in pure DOS is a RAM drive?
|
|
| Floor11 redtek | Posted 2006-09-28 06:19 |
| 金牌会员 Posts 1,147 Credits 2,902 | |
|
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... |
|
| Floor12 weilong888 | Posted 2006-09-28 08:09 |
| 银牌会员 Posts 548 Credits 1,270 | |
|
for and if are powerful.
|
|
| Floor13 namejm | Posted 2006-09-28 10:33 |
| 荣誉版主 Posts 1,737 Credits 5,226 From 成都 | |
Originally posted by redtek at 2006-9-26 06:20: 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 |
|
| Floor14 Jnwei1202 | Posted 2006-09-28 21:28 |
| 初级用户 Posts 33 Credits 197 | |
|
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 ] |
|
| Floor15 NaturalJ0 | Posted 2006-09-28 22:04 |
| 银牌会员 Posts 533 Credits 1,181 | |
|
Then load the NTFS driver first
|
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |