step1_1.bat- @echo off
- setlocal enabledelayedexpansion
- for /f "tokens=1-9 delims=: " %%a in ('type "diskpart.txt" ^| findstr /n ".*"') do (
- if "%%d" equ "联机" (
- if "%%i" equ "*" (
- set "_%%b %%c=GPT"
- ) else (
- set "_%%b %%c=MBR"
- )
- )
- if "%%b" equ "磁盘" (
- set "DiskNum=%%c"
- set MaxMB=0
- set MaxGB=0
- set DiskLine=%%a
- )
- if "%%d" equ "系统" (
- set "StrDisk=磁盘 !DiskNum!"
- call set strPT=%%_!StrDisk!%%
- call :MaxPartition !DiskLine!
- if !MaxGB! neq 0 (
- set "strPartition=分区!PartitionNumG!"
- ) else if !MaxMB! neq 0 (
- set "strPartition=分区!PartitionNumM!"
- )
- goto :EndStep1_1
- )
-
- )
- goto :eof
-
- :MaxPartition
- for /f "skip=%1 tokens=1-8" %%a in ('type "diskpart.txt"') do (
- if "%%a" neq "磁盘" (
- if "%%e" equ "MB" (
- if %%d gtr !MaxMB! (
- set MaxMB=%%d
- set PartitionNumM=%%b
- )
- ) else if "%%e" equ "GB" (
- if %%d gtr !MaxGB! (
- set MaxGB=%%d
- set PartitionNumG=%%b
- )
- )
- ) else (
- goto :eof
- )
- )
- goto :eof
-
- :EndStep1_1
- set StrResult1_1=!StrDisk: =!!strPartition!,!strPT!,最大!strPartition!
- >"0.txt" echo !StrResult1_1!
复制代码
|