![]() |
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-12 03:19 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » fsutil fsinfo drives |
| Printable Version 2,979 / 18 |
| Floor1 Eblis | Posted 2007-01-13 09:39 |
| 中级用户 Posts 108 Credits 251 From 湖南==>广州 | |
|
There is no error in the code itself in terms of basic syntax. However, the issue might be that when you do `set drivers=%%i`, if there are multiple drives, this will only capture the last drive. Also, the way you are parsing the `drives.txt` file might need to be adjusted depending on exactly what you are trying to achieve. But based on the provided code, the error as described "why can't set drivers" is a bit unclear. The code is supposed to capture the drive letters from `drives.txt` after skipping the first line and then set the `drivers` variable to each drive letter, but if you want to collect all drives, you need to accumulate them instead of just overwriting `drivers` each time.
In English: There is no inherent error in the code itself in terms of basic syntax. However, the problem might be that when you do `set drivers=%%i`, if there are multiple drives, this will only capture the last drive. Also, the way you are parsing the `drives.txt` file might need to be adjusted depending on exactly what you are trying to achieve. But based on the provided code, the statement "why can't set drivers" is a bit unclear. The code is supposed to capture the drive letters from `drives.txt` after skipping the first line and then set the `drivers` variable to each drive letter, but if you want to collect all drives, you need to accumulate them instead of just overwriting `drivers` each time. |
|
| Floor2 Eblis | Posted 2007-01-13 10:31 |
| 中级用户 Posts 108 Credits 251 From 湖南==>广州 | |
|
Oh, come on... Help me, please``
|
|
| Floor3 Eblis | Posted 2007-01-13 10:44 |
| 中级用户 Posts 108 Credits 251 From 湖南==>广州 | |
|
Still want to ask a question.. Can find not search for 2 strings??
For example, find /i "1.txt" "2.txt" 3.txt Search for the two strings 1.txt and 2.txt in the 3.txt file.. |
|
| Floor4 Eblis | Posted 2007-01-13 10:52 |
| 中级用户 Posts 108 Credits 251 From 湖南==>广州 | |
|
The problem on the 3rd floor has found an answer... The findstr command can be used... Help answer the question on the 1st floor.
|
|
| Floor5 Eblis | Posted 2007-01-13 11:31 |
| 中级用户 Posts 108 Credits 251 From 湖南==>广州 | |
|
Brothers, please help out, yeah.
|
|
| Floor6 Eblis | Posted 2007-01-13 11:53 |
| 中级用户 Posts 108 Credits 251 From 湖南==>广州 | |
|
fsutil fsinfo drives >drives.txt
for /f "skip=1 tokens=1* delims=:" %%I in (drives.txt) do @set drives=%%I %%j I just want to take the : drive: C:\ D:\ E:\ F:\ G:\ H:\ in drives.txt and set drives=c d e f g h |
|
| Floor7 dikex | Posted 2007-01-13 14:01 |
| 高级用户 Posts 366 Credits 788 | |
|
I found that the drives.txt generated by fsutil fsinfo drives >drives.txt has content, but there are many 00s in its ASCII code! The content of a.txt was copied from drives.txt (the size is also 32 bytes when checked), but look at the result of FC /b comparison
The following code also has a problem... for /f "skip=1 tokens=2-6 delims=:\" %i in ('fsutil fsinfo drives') do echo %i %j %k %l %m %n Only %i is displayed successfully, but when 'fsutil fsinfo drives' is replaced with the above a.txt, it is successful... It seems that the output of fsutil fsinfo drives is problematic... This time running fc drives.txt a.txt gets the result
But using for /f %i in (a.txt) do echo %i can only display "Drive:" [ Last edited by dikex on 2007-1-13 at 02:56 PM ] |
|
| Floor8 Eblis | Posted 2007-01-13 16:31 |
| 中级用户 Posts 108 Credits 251 From 湖南==>广州 | |
|
I don't know how the brother above copied.. There is no difference here for me.
G:\DOS\BAT>fc /b drives.txt 1.txt Comparing files drives.txt and 1.TXT FC: no differences encountered G:\DOS\BAT>fc /b drives.txt 2.txt Comparing files drives.txt and 2.TXT FC: no differences encountered 1.txt is the content of the file copied.. 2.txt is copy drives.txt.. there are no differences.. |
|
| Floor9 Eblis | Posted 2007-01-13 17:12 |
| 中级用户 Posts 108 Credits 251 From 湖南==>广州 | |
|
for /f "skip=1 tokens=2-10 delims=:\ " %%a in (2.txt) do @set drives=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j
Why does this line later display set drives=c d e f g h %j |
|
| Floor10 Eblis | Posted 2007-01-13 17:38 |
| 中级用户 Posts 108 Credits 251 From 湖南==>广州 | |
|
Really can't figure it out..各位高手..
Could it be that I need to use the so-called variable delay???? I'm almost depressed.. I first used fsutil fsinfo drives >1.txt then type 1.txt >2.txt then execute the for statement and still can't succeed... |
|
| Floor11 Eblis | Posted 2007-01-13 18:08 |
| 中级用户 Posts 108 Credits 251 From 湖南==>广州 | |
|
***** drives.txt
Drive: C:\ D:\ E:\ F:\ G:\ I kind of understand why only one C is displayed.. Although when we output fsutil fsinfo drives to a text, it's in one line.. But actually it's displayed with line breaks.. So for can only display a single string.... |
|
| Floor12 Eblis | Posted 2007-01-13 22:19 |
| 中级用户 Posts 108 Credits 251 From 湖南==>广州 | |
|
The test is completed.. It's impossible to display.. The first two lines before ASCII code display are carriage returns.. I'm not clear... Hope experts can explain why it displays like this...
|
|
| Floor13 zh159 | Posted 2007-01-14 00:11 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
fsutil fsinfo drives|find /v "">drives.txt
|
|
| Floor14 dikex | Posted 2007-01-14 04:30 |
| 高级用户 Posts 366 Credits 788 | |
Originally posted by Eblis at 2007-1-13 03:31 AM: Double-click to open that text, then select all, copy, create a new text, and paste Let's take a look at the comparison result of WinHex in the following figure. The 20 was the 00 end mark before copying above, so when for was processing these strings, it encountered 00 and thought it was the end and didn't continue processing, so it naturally couldn't get the result we wanted. That is to say, for the for command, the data it needs to process is only Drive: C:\ and so on. Therefore, for /f "skip=1 tokens=2-6 delims=:\" %i in ('fsutil fsinfo drives') do echo %i %j %k %l %m %n and for /f %i in (a.txt) do echo %i can only display part of it [ Last edited by dikex on 2007-1-13 at 03:31 PM ] Attachments 未命名.JPG (45.46 KiB) |
|
| Floor15 zh159 | Posted 2007-01-14 05:45 |
| 金牌会员 Posts 1,467 Credits 3,687 | |
|
I used to play with a segment of code for finding drive letters and modifying them. I feel it's slightly more efficient than the one on floor 15.
|
|
| 1 2 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |