PowerShell Split Big file in minitus

$SRC_FILE= "$Root\Payment\Payment_Account_Staging_bkp.csv" 
$rootName = "$Root\Payment"                             
 

#can change the file extinction to csv $upperBound = 200MB   
#chnage the number based on the requiremnt
$rootName1="$rootName\Payment"       

 Write-Host $Root

 $SRC_FILE_BUFR = [io.file]::OpenRead($SRC_FILE)
 $SRC_buff = new-object byte[] $upperBound
 $count = $idx = 0
 try 
      {    
        do {  
 $count = $SRC_FILE_BUFR.Read($SRC_buff, 0, $SRC_buff.Length)     
 if ($count -gt 0) {
                  $Out = "{0}.{1}.{2}" -f ($rootName1, $idx, $ext) 
                     $OutFile = [io.file]::OpenWrite($out)           
 try {                
         "Writing $count to $to"               
         $Outfile.Write($SRC_buff, 0, $count)           
 } 
 finally 
 {               
 $Outfile.Close()            
 }        
 }       
 $idx ++    
 } 
 while ($count -gt 0)}finally {$SRC_FILE_BUFR.Close()}

Continue reading

Advertisements