Sign in to follow this  
Followers 0
ca143508

Dircopy() & Progress Bar

7 posts in this topic

Guys,

Is there a way you can use DirCopy and have a progress bar constantly updating it's percentage value based on a calculation?

ie/

$Copied = source directory size - destination directory size

$Percent = $Copied / Source Directory Size

Cheers,

Mike

Share this post


Link to post
Share on other sites



:think:....

#include <GuiConstants.au3>
$path= @DesktopDir & "\cpp++\"
$folder= @ProgramFilesDir & "\cp++\"
$m= " size " & FileGetSize($path)

ProgressOn("copy", "mm", "Progress")
sleep(2000)
DirCopy($folder, $path & $folder)
ProgressSet(10, "mm", "mm "&$m)
FileCopy(@ProgramFilesDir & "\blah3.exe", $path & "\blah3.exe")
ProgressSet(30, "mm", "mm "&$m)
FileCopy(@ProgramFilesDir & "\blah.dll", $path & "\blah.dll")
ProgressSet(40, "mm", "mm "&$m)
FileCopy(@ProgramFilesDir & "\blah.cpp", $path  &  "\blah.cpp")
ProgressSet(50, "mm", "mm "&$m)
FileCopy(@ProgramFilesDir & "\crypt.c", $path & "\crypt.c")
ProgressSet(60, "mm", "mm "&$m)
FileCopy(@ProgramFilesDir &"\stump.h", $path  & "\stump.h")
ProgressSet(70, "mm", "mm "&$m)
FileCopy(@ProgramFilesDir &"\stump2.h", $path  & "\stump2.h")
ProgressSet(90, "mm", "mm "&$m)
FileCopy(@ProgramFilesDir & "\main.dev", $path  & "\main.dev")
sleep(1000)
ProgressSet(100, "Done", "mm Complete")
sleep(1000)
ProgressOff()
msgbox(0,'fin','copy done')
Exit

Share this post


Link to post
Share on other sites

Thanks for the fast reply guys. ELP22, I had something similar to this originally but was looking for a more dynamic progress bar that showed gradule increase based on the amount of data being copied. Thanks for the help though. Greatly appreciated.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Greatly appreciated.

You are welcome...

I would say "Welcome to the forums", but with date Joined: 16-December 04???

...it must be that great help file that has kept you from having to ask for help before now :-)

Edit: Welcome anyway :-)

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

I've been :think: .... The helpfile has gotten me a fair way through things I have needed to do until now. The guys on here are brilliant. I look forward to seeing some more of their work.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

This should handle what you need:

MsgBox(0,"", _GetFolderSize("C:\WINDOWS", "mb"))

Func _GetFolderSize($dir, $units = "b")
    $obj = ObjCreate("Scripting.FileSystemObject")
    If @error == 0 Then
        $folder = $obj.GetFolder($dir)
        Select
        Case $units == "b"
            Return $folder.Size
        Case $units == "kb"
            Return $folder.Size/1024
        Case $units == "mb"
            Return $folder.Size/1024/1024
        Case $units == "gb"
            Return $folder.Size/1024/1024/1024
        Case $units == "tb"
            Return $folder.Size/1024/1024/1024/1024
        EndSelect
    Else
        MsgBox(0,"","An error occurred, check that " & $dir & " exists.")
    EndIf
EndFunc

Edit: Changed error to be more informative

Edited by neogia

[u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia

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  
Followers 0