Sign in to follow this  
Followers 0

Help Needed - ProgessBar Updates While Copying Dirs

4 posts in this topic

Hi guys -

I think I'm overcomplicating what I'm trying to achieve and I need help simplifying my thought process:

PROBLEM DOMAIN: I have a series of folders on the network that I want to copy locally while having a GUI progress bar update according to how may files are left to be copied. The easiest solution would be to use DirCopy but then updating the GUI progress' bar will move in too big of jumps. I want the progress bar smooth and relatively accurate.

IDEA: My idea is that you would have a function that would recursively drilldown into the directories getting all subdirectory paths (that alone has been a tough nut for me to crack), then calculate how many files are in each, add them together and use FileCopy instead of DirCopy in order to update the progress bar using modulus to update the progress bar every X number of files processed.

Is that overcomplicating things? There must be an easier way. Does anybody have any helpful suggestions or code examples I could use? Thanks in advance.

Share this post

Link to post
Share on other sites

#3 ·  Posted (edited)


just a quick try:

;Copy with Progressbar
#Include <File.au3>

_copyProgress("c:\Downloads\Musik\Hütten Charts 2005\CD 1", "c:\Downloads\AutoIt-Skripte\Entwicklung\ForumTests\Mp3Test")

Func _copyProgress($From_dir, $Dest_dir, $filter = '*.*')
    Local $count = 0, $dir = ""
    $FileList = _FileListToArray($From_dir, $filter, 0)
    If (Not IsArray($FileList)) And (@error = 1) Then SetError(-1)
    ProgressOn("Copy", "Files :", "0 files")
    For $i = 1 To UBound($FileList) - 1
        If FileGetAttrib($FileList[$i]) = "D" Then $dir = "\*.*"
        If FileCopy($From_dir & "\" & $FileList[$i] & $dir, $Dest_dir & "\", 9) Then
            $count += 1
            ProgressSet($count * 100 / $FileList[0], _
                    "From: " & $From_dir & "\" & @LF & "To: " & $Dest_dir & "\" & @LF & $FileList[$i], _
                    Round(($count * 100 / $FileList[0]),2) & " % " & @TAB & $count & "/" & $FileList[0] & " Done")
    ProgressSet(100, "Done", "Complete")
    Return 1
EndFunc   ;==>_copyProgress

Edit: a bit shorter :lmao:

So long,


Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post

Link to post
Share on other sites


just a quick try: [...]

That ProgressOn is pretty neat. You just gave me another interesting option. Thank you very much.

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