Jump to content
Sign in to follow this  
themax90

Progress bar for dir size

Recommended Posts

I have been trying alot to figure this out but I guess my brain is just FROZEN!!!!

Can someone find a way or give an example of something like:

While FileInstall ( Files, Directory )

If Directory - Proportional to percent Then

ProgressSet( That Percent )

EndIf

WEnd

Something like that. Thanks, I been working awhile and to me it's a brain buster!

Share this post


Link to post
Share on other sites

Fileinstall is a blocking function AFIAK therefore all other functions including progress bars won't work anyway.


Who else would I be?

Share this post


Link to post
Share on other sites

People really want strange things... The only way I can think, is using two scripts. Like this, untested and wrote directly from the top of my head:

Script 1

FileWrite(@tempdir & '\working.tmp','')
;Starts the other script here with a ShellExecute DLLCALL
DirCreate('c:\dest')
FileInstall('yourbigfile.exe','c:\dest')
FileDelete(@tempdir & '\working.tmp')

Script 2

ProgressOn('Proceed','')
While FileExists(@tempdir & '\working.tmp')
   Sleep(100)
   $percent = 100 * DirGetSize('c:\dest') / $expectedsize
   ProgressSet($percent)
WEnd
ProgressOff()

Share this post


Link to post
Share on other sites

Well how about a file copy. How did Tidy create a installer. I want to great an installer but IN AUTOIT. If anyone has the brains to figure it out.....

Share this post


Link to post
Share on other sites

i have also faced this small problem ... i was making a script to backup a directory to another .... the problem is .... this gets the size of the original directory and compares it to the size of the copied one ... its all good ... except ...... if you backup the folder to another directroy that already has files/folders in it the directroy size will be larger than the original .. stuffing everything outa whack ... this is wat i got so far

also .. if u use DirCopy function .. it copies the files first b4 showing the progress bar .. so wat i had to do is call xcopy.exe so that the progress bar unpdates while the files are being copied ... and there are sum minor other bugs also not mentioned

#include <file.au3>

$OrigDirect = FileSelectFolder("Please select the folder you wish to backup.", "")
If @error = 1 Then
   Exit
Else
   $CopyDirect = FileSelectFolder("Where would you like to backup this folder to.", "", 1)
   If @error = 1 Then
      Exit
   Else
      CopyFolder($OrigDirect, $CopyDirect)
   EndIf
EndIf

Func CopyFolder($Folder1, $Folder2)

$TempOrig = @TempDir & "\OrigTemp.txt"
$OrigSearch = FileFindFirstFile($OrigDirect & "\*.*") 
_FileCreate ($TempOrig)
$OpenOrig = FileOpen($TempOrig, 1)

While 1
   $OrigFile = FileFindNextFile($OrigSearch) 
   If @error Then ExitLoop
   FileWrite($OpenOrig, $OrigFile & @CRLF)
Wend

FileClose($OpenOrig)

$CountLines = _FileCountLines(@TempDir & "\origtemp.txt")

   Local $ProcID
   $ProcID = Run(@ComSpec & ' /c xcopy /e /h /y "' & $Folder1 & '" "' & $Folder2 & '"', "", @SW_HIDE)
  
   ProgressOn("Progress Meter", "Copy in progress.", 16)
  
   $OrigFileSize = DirGetSize($Folder1)

   Do
  
      $CopyFileSize = DirGetSize($Folder2)
      
      $MBCopy = DirGetSize($Folder2) / 1024 / 1024

      $Percent = $CopyFileSize / $OrigFileSize * 100
      
      $DecimalPlace = Round ($Percent)
      $DecimalPlaceMBCopy = Round ($MBCopy)


ProgressSet ($percent, $DecimalPlace  & "% " & "(" &  $DecimalPlaceMBCopy & ") Mb has been copied.")
EndIf

      Sleep(500)

   Until NOT ProcessExists($ProcID)
  
   ProgressOff ()

   $CopyFileSize = DirGetSize($Folder2)
   $MBOrig = DirGetSize($Folder1) / 1024 / 1024
   $DecimalPlaceMBOrig = Round ($MBOrig)

$TempCopy = @TempDir & "\CopyTemp.txt"
$CopySearch = FileFindFirstFile($CopyDirect & "\*.*") 
_FileCreate ($TempCopy)
$OpenCopy = FileOpen($TempCopy, 1)

While 1 
   $CopyFile = FileFindNextFile($CopySearch)
   If @error Then ExitLoop
   FileWrite($OpenCopy, $CopyFile & @CRLF)
Wend

FileClose($OpenCopy)
      
$Text = FileRead($TempOrig, FileGetSize($TempOrig))
$H_Input = FileOpen($TempCopy, 0)
$count = 0
While 1
    $Word = FileReadLine($H_Input)
    If @error Then ExitLoop
    If StringInStr($Text, $Word) Then
        $Count = $Count + 1
    Else
        $Count = $Count
    EndIf
WEnd

If $Count = $CountLines Then
Msgbox(0,"Backup Complete", "All " & $Count - 2 & " Files/Folders were copied successfully.")
   Else
      Msgbox(0,"Error!", "The backup did not complete successfully. Only " & $Count - 2 & " File/Folders copied successfully.")
   EndIf

FileDelete ($TempOrig)
FileDelete ($TempCopy)

EndFunc

qq

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...