echo Enter the size of each partition (unit: GB), separated by spaces or commas, and do not enter the last partition:
set size=
Set /P size=Partition sizes:
echo.
::Comment starts from here;
echo Enter "NTFS" or "FAT" to format accordingly, enter "N" or omit to not format:
::Delete the frmt variable
set frmt=
::User enters the value of the frmt variable (NTFS or FAT)
Set /P frmt=:
::Delete the frmt variable
set frmty=
:: The following if statement is to set the values of frmty and ss variables.
:: Among them, the frmty variable stores the parameters of Gdisk32
:: /for is to format the partition; /q is quick format /ntfs specifies the partition format
:: The algorithms for the two partition formats are different. The ss variable stores the base number. It will be used below
If /I '%frmt%'=='ntfs' set frmty=/for /q /ntfs&&set ss=1024
If /I '%frmt%'=='fat' set frmty=/for /q&&set ss=1028-8
echo Starting partitioning, please wait...
echo Partition process information:
::Take out each partition size value entered by the user, up to 9 partitions can be set
for /f "tokens=1,2,3,4,5,6,7,8,9 delims=, " %%c in ("%size%") do (
rem Convert the partition size value entered by the user (GB unit) to MB unit. That is, numerical value * SS variable value
rem For example, for NTFS partition: GB value * 1024
set /A cp=%%c*%ss%
rem The following two lines divide the first primary partition and activate
GDISK32 1 /cre /pri /sz:!cp! %frmty%
GDISK32 1 /act /p:1
rem The following line divides the remaining space into extended partitions
GDISK32 1 /cre /ext
rem The following For loop is to divide logical partitions. Up to eight
for %%i in (%%d,%%e,%%f,%%g,%%h,%%i,%%j,%%k) do (
set /A op=%%i*%ss%
GDISK32 1 /cre /log /sz:!op! %frmty%
))
::Divide the remaining space into a logical partition
GDISK32 1 /cre /log /end %frmty%
echo.
echo Partition completed!
[ Last edited by wewebb on 2010-11-20 at 14:28 ]