Jump to content

Recommended Posts

Posted

An1B,

This accounts for any number of digits following the "=" sign. I also provided for keywords being seperated by one or more spaces, except that the

"=" sign has to be preceeded and followed by characters (no spaces).

If you use this you should provide some checking at the end to ensure that the final file is what you expect.

#include <array.au3>

;-------------------------------------------------------------------------------
; read the file and declare some vars
;-------------------------------------------------------------------------------

local $diskpart_str = fileread( @scriptdir & '\diskpart.txt'), $aret, $tot_space

;-------------------------------------------------------------------------------
; add the values we want to accumulate
;-------------------------------------------------------------------------------

$aret = stringregexp($diskpart_str,'(?i)create\s+partition\s+primary\s+size=(\d+)',1)
$tot_space += $aret[0]

$aret = stringregexp($diskpart_str,'(?i)create\s+partition\s+efi\s+size=(\d+)',1)
$tot_space += $aret[0]

$aret = stringregexp($diskpart_str,'(?i)create\s+partition\s+msr\s+size=(\d+)',1)
$tot_space += $aret[0]

$aret = stringregexp($diskpart_str,'(?)shrink minimum=(\d+)',1)
$tot_space += $aret[0]

ConsoleWrite($tot_space & @LF)

;-------------------------------------------------------------------------------
; find the last occurence of "create partition primary size=" and overwrite size
;-------------------------------------------------------------------------------

local $aTemp = stringsplit($diskpart_str,@crlf,1)

for $1 = $aTemp[0] to 1 step -1
    if stringinstr($aTemp[$1],'create partition primary size=') > 0 then
        $aTemp[$1] = ' create partition primary size=' & $tot_space
        exitloop
    endif
next

filewrite(@scriptdir & '\diskpart_new.txt',_arraytostring($aTemp,@crlf))

shellexecute(@scriptdir & '\diskpart_new.txt')

Good Luck,

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

Hi guys ,

sorry for my delay ...

A big thanks to all for advice and source .....today i completed all the steps and now is necessary merge them

BRs

An1B.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...