标题: [文本处理] [已解决]获取磁盘信息的批处理为何变量不能正常显示? [打印本页]
作者: a262615704 时间: 2011-10-9 20:33 标题: [已解决]获取磁盘信息的批处理为何变量不能正常显示?
Disk: 1 (149.05GB) M:[WDC WD1600AAJS-22PSA0] S:[WD-WCAP91806016]
1.1: ( 10.01GB) [G:\] Active Volume NTFS l:[GO7]
1.2: ( 18.94GB) [D:\] Volume NTFS l:[PAGE]
1.3: ( 100.09GB) [E:\] Volume NTFS l:[DATA]
1.4: ( 10GB) [F:\] Volume NTFS l:[WIN7]
1.5: ( 10GB) [C:\] Volume NTFS l:[WINXP]
( 2.49MB) Unused Space
Disk: 2 (7.50GB) M:[Ut165 USB Flash Disk 0.00]
2.1: ( 7.49GB) [I:\] Active Volume NTFS l:[时尚蛤蟆]
( 6.33MB) Unused Space- @echo off
- echo.
- echo.
- echo *********************************
- echo.
- setlocal enabledelayedexpansion
- for /f "tokens=1-3 delims=() " %%a in (info.txt) do (
- if "%%a" == "Disk:" (
- set /a value+=1
- set disk!value!=%%c
- for /f "tokens=1-7 delims=() " %%a in (info.txt) do (
- if "%%a" == "!value!.1:" (
- set par!value!=%%b
- set vol!value!=%%g
- echo !vol%value%! //显示不出来,这是什么原因
- )
- )
- )
- )
- echo 磁盘总数:%value%
- echo.
- for /l %%a in (1,1,%value%) do (
- if defined disk%%a (
- echo 磁盘 %%a 总容量:!disk%%a!
- if defined par%%a (
- echo 分区 1 的容量:!par%%a!
- )
- echo.
- )
- )
- echo *********************************
-
- pause>nul
复制代码
作者: a262615704 时间: 2011-10-9 20:34
- @echo off
- setlocal enabledelayedexpansion
- set value=50
- set vol%value%=500
- echo !vol%value%!
- pause
复制代码
而上面这个显示正常
作者: 601997526 时间: 2011-10-9 21:07
因为是在for内
把echo !vol%value%!
改为
call call echo %%%%vol%%value%%%%%%
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |