Jump to content

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 )



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

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
FileDelete(@tempdir & '\working.tmp')

Script 2

While FileExists(@tempdir & '\working.tmp')
   $percent = 100 * DirGetSize('c:\dest') / $expectedsize
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
   $CopyDirect = FileSelectFolder("Where would you like to backup this folder to.", "", 1)
   If @error = 1 Then
      CopyFolder($OrigDirect, $CopyDirect)

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)


$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)

      $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.")


   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)

$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
        $Count = $Count

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

FileDelete ($TempOrig)
FileDelete ($TempCopy)



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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...