本帖最后由 lanfogz 于 2019-2-25 09:45 编辑
获取磁盘的数量、所有磁盘的大小- @echo off & setlocal enabledelayedexpansion
-
- set disk_count=0
- for /f "tokens=2" %%i in ('wmic path win32_diskdrive get deviceid^,size^| findstr ^^[0-9] ^|sort') do (
- set disk!disk_count!_size=%%i
- set/a disk_count+=1
- )
-
- echo 磁盘数量:%disk_count%
- for /l %%i in (0, 1, %disk_count%) do if %%i lss %disk_count% (echo 磁盘%%i大小:!disk%%i_size!)
复制代码
|