|
lianjiang2004
金牌会员
     
积分 3946
发帖 1884
注册 2006-1-20
状态 离线
|
『楼 主』:
请教:如何用批处理判断某一扇区为空闲扇区?
使用 LLM 解释/回答一下
请教:如何用批处理判断某一扇区为空闲扇区?
比如我用软件读取39扇区后,得到的文件为039.txt,格式如下:
--------------
Disk 0 Absolute Sector 39
00000004E00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
。。。。。
略去
------------------
我用的批处理如下,麻烦各位给看看,哪里除了问题。
----------
rem @echo off
if exist %temp%\039.txt del %temp%\039.txt >nul
diskrw 0 39 1 /l >%temp%\039.txt
For /f "tokens=1-2 delims=:" %%i In ('type %temp%\039.txt ^| find ":"') do (
set sector=%%j
echo sector is "%sector%"
pause
if not "%sector%"==" 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " goto sector_2c
)
:sector_2d
echo 39扇区为空闲扇区。
echo.
pause
goto sector_2b
:sector_2c
echo 39扇区不是空闲扇区。
echo.
pause
:sector_2b
Last edited by lianjiang2004 on 2007-6-4 at 05:00 PM ]
Ask: How to use batch processing to determine whether a certain sector is an idle sector?
For example, after I use software to read sector 39, the obtained file is 039.txt, and the format is as follows:
--------------
Disk 0 Absolute Sector 39
00000004E00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00000004E90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
。。。。。
Omitted
------------------
The batch processing I used is as follows, please help everyone to see, where is the problem.
----------
rem @echo off
if exist %temp%\039.txt del %temp%\039.txt >nul
diskrw 0 39 1 /l >%temp%\039.txt
For /f "tokens=1-2 delims=:" %%i In ('type %temp%\039.txt ^| find ":"') do (
set sector=%%j
echo sector is "%sector%"
pause
if not "%sector%"==" 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " goto sector_2c
)
:sector_2d
echo Sector 39 is an idle sector.
echo.
pause
goto sector_2b
:sector_2c
echo Sector 39 is not an idle sector.
echo.
pause
:sector_2b
Last edited by lianjiang2004 on 2007-6-4 at 05:00 PM ]
|

Windows 一键还原
http://www.yjhy.com |
|
2007-6-4 16:58 |
|
|
lianjiang2004
金牌会员
     
积分 3946
发帖 1884
注册 2006-1-20
状态 离线
|
|
2007-6-4 17:01 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
没有启用变量延迟。
在批处理的开始加上“SetLocal EnableDelayedExpansion”,再把%sector%改成!sector!试试,不行再跟帖讨论。
Variable delay is not enabled. Add "SetLocal EnableDelayedExpansion" at the beginning of the batch, then try changing %sector% to !sector!. If it doesn't work, post a follow-up to discuss.
|
|
2007-6-4 17:16 |
|
|
lianjiang2004
金牌会员
     
积分 3946
发帖 1884
注册 2006-1-20
状态 离线
|
|
2007-6-4 17:20 |
|
|
qzwqzw
银牌会员
     天的白色影子
积分 2343
发帖 636
注册 2004-3-6
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
即使所有数据为0
也不保证这个扇区未被使用
更不保证这个扇区将不会使用
所以这只能是辅助的判定办法
还需要依靠其他的办法来做主判定
Even if all data is 0 it does not guarantee that this sector is unused nor does it guarantee that this sector will not be used so this can only be an auxiliary judgment method and other methods are still needed for the main judgment
|
|
2007-6-4 18:16 |
|
|
lianjiang2004
金牌会员
     
积分 3946
发帖 1884
注册 2006-1-20
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
Originally posted by qzwqzw at 2007-6-4 18:16:
即使所有数据为0
也不保证这个扇区未被使用
更不保证这个扇区将不会使用
所以这只能是辅助的判定办法
还需要依靠其他的办法来做主判定
请教有何主判定法?
我想用的是一个保留扇区里的一个空闲扇区。
一般软件是不会用的,我想也无需保证将不会被用。呵呵,就像别人能用,我也能用,我想只要是还没用的就行吧。
Originally posted by qzwqzw at 2007-6-4 18:16:
Even if all data is 0
It does not guarantee that this sector is unused
Nor does it guarantee that this sector will not be used
So this can only be an auxiliary judgment method
Other methods are still needed for the main judgment
Please teach me what the main judgment method is?
I want to use an idle sector in a reserved sector.
General software will not use it, and I think there is no need to guarantee that it will not be used. Hehe, just like others can use it, I can also use it. I think as long as it is not used yet.
|

Windows 一键还原
http://www.yjhy.com |
|
2007-6-4 18:23 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
Originally posted by lianjiang2004 at 2007-6-4 17:20:
还是无值。只是显示成 sector is "!sector!"。
帮你试过 可以的啊!
sector is " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
请按任意键继续. . .
39扇区不是空闲扇区。
请按任意键继续. . .
Originally posted by lianjiang2004 at 2007-6-4 17:20:
Still no value. Just displayed as sector is "!sector!".
Helped you test it, it's okay!
sector is " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
Press any key to continue...
Sector 39 is not an idle sector.
Press any key to continue...
|
|
2007-6-4 18:38 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
怎么会没有呢?
我这里测试正常。
@echo off
SetLocal EnableDelayedExpansion
For /f "tokens=1-2 delims=:" %%i In ('type 009.txt ^| find ":"') do (
set sector=%%j
echo sector is "!sector!"
pause
if not "%sector%"==" 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " goto sector_2c
)
pause
How could there be none?
It tests normally here.
@echo off
SetLocal EnableDelayedExpansion
For /f "tokens=1-2 delims=:" %%i In ('type 009.txt ^| find ":"') do (
set sector=%%j
echo sector is "!sector!"
pause
if not "%sector%"==" 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " goto sector_2c
)
pause
|
|
2007-6-4 18:41 |
|
|
lianjiang2004
金牌会员
     
积分 3946
发帖 1884
注册 2006-1-20
状态 离线
|
|
2007-6-4 18:52 |
|
|
lianjiang2004
金牌会员
     
积分 3946
发帖 1884
注册 2006-1-20
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
我想要的是有不为“ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 “的行才显示不是空闲扇区,怎么全是0,也显示不是空闲扇区了?我的批处理中哪里还有问题?
What I want is to display only the lines that are not "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" as non-free sectors. Why are all 0s also displayed as non-free sectors? What's wrong in my batch script?
|

Windows 一键还原
http://www.yjhy.com |
|
2007-6-4 18:55 |
|
|
lianjiang2004
金牌会员
     
积分 3946
发帖 1884
注册 2006-1-20
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
知道了,要改成 if not "!sector!"==" 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " goto sector_2c
Got it, it should be changed to if not "!sector!" == "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00" goto sector_2c
|

Windows 一键还原
http://www.yjhy.com |
|
2007-6-4 18:58 |
|
|
lianjiang2004
金牌会员
     
积分 3946
发帖 1884
注册 2006-1-20
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
请教,为何开头部分一定要加上“SetLocal EnableDelayedExpansion”
以前用的类似批处理,没有也行的。就像1楼的批处理那样。
Ask, why must the beginning part add "SetLocal EnableDelayedExpansion"? The similar batch processing I used before didn't need it. Just like the batch processing in building 1.
|

Windows 一键还原
http://www.yjhy.com |
|
2007-6-4 19:01 |
|
|
lxmxn
版主
       
积分 11386
发帖 4938
注册 2006-7-23
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
以“变量延迟”为关键字搜索一下。
Search for the keyword "variable delay".
|
|
2007-6-4 19:05 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
拿掉第一个pause 更方便一点嘛
It's more convenient to remove the first pause.
|
|
2007-6-4 19:15 |
|
|
lianjiang2004
金牌会员
     
积分 3946
发帖 1884
注册 2006-1-20
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
因为批处理没通过,所以在差错,也就多了一些显示的地方。
发现那里变量无值,所以才来请求帮助的。解决了,当然要去掉无用信息,要结果即可。多谢。
Because the batch processing didn't pass, so I'm checking for errors, which has resulted in more display areas. I found that the variable there has no value, so I came to ask for help. Once solved, of course, I need to remove the useless information and just get the result. Thanks a lot.
|

Windows 一键还原
http://www.yjhy.com |
|
2007-6-4 19:20 |
|