Sign in to follow this  
Followers 0
M1chael

Dircopy progressbar... (pure AutoIT)

4 posts in this topic

Hey

This is my first post in the forum, so forgive me the typo's...

I've been looking around the forum for a simple progressbar wich displays during DirCopy. There are many different ways off doing this, but none that was quite simple enough for my use.

So i've created this small simple function, wich display the progress of "xcopy" by counting the files in the source and destination dir. I know this is not 100% progress, but it's better then nothing...

(The reson i'm not using DIR size, is because NTFS predicts the size of the copy, and will therefore display 100% in a manor of secunds...)

CODE

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.12.1

Author: Michael Østergaard Sørensen

Script Function:

Simple copyprogress bar, using xcopy.

#ce ----------------------------------------------------------------------------

;Include

#include <GuiConstants.au3>

#include <file.au3>

COPYPROGRESS("D:\Medier\DiVX","c:\Temp\DiVX")

Func COPYPROGRESS($x,$y)

If FileExists($y) = 0 Then

DirCreate($y)

EndIf

Run(@ComSpec & " /c " & 'xcopy "' & $x & '\*.*" "' & $y & '\*.*" /s/r/v/y',"")

$source = DirGetSize($x,1)

$dest = DirGetSize($y,1)

Sleep(500)

ProgressOn("","Copying",$dest[1] & " of " & $source[1] & " files copied")

While $dest[1] < $source[1]

$dest = DirGetSize($y,1)

Sleep(100)

$progress = ($dest[1] / $source[1]) * 100

ProgressSet($progress,$dest[1] & " of " & $source[1] & " files copied")

Sleep(100)

WEnd

ProgressSet(100,"Done!")

Sleep(500)

ProgressOff()

EndFunc

COPYPROGRESS.au3

Share this post


Link to post
Share on other sites



Look an example:

#include <File.au3>
$GUI = GUICreate("Copy files",350,100)
$PATH1 = GUICtrlCreateInput(@ScriptDir,5,5,270,20)
$BROWSE1 = GUICtrlCreateButton("BROWSE",280,5,65,20)
$PATH2 = GUICtrlCreateInput(@DesktopDir,5,30,270,20)
$BROWSE2 = GUICtrlCreateButton("BROWSE",280,30,65,20)
$COPY = GUICtrlCreateButton("COPY",150,60,50,30)
GUISetState(@SW_SHOW,$GUI)

While 1
    $MSG = GUIGetMsg()
    Select
        Case $MSG = $BROWSE1
            $PATH = FileSelectFolder("Select path",@ScriptDir,1)
            If Not @error Then
                GUICtrlSetData($PATH1,$PATH)
            EndIf
        Case $MSG = $BROWSE2
            $PATH = FileSelectFolder("Select path",@ScriptDir,1)
            If Not @error Then
                GUICtrlSetData($PATH2,$PATH)
            EndIf
        Case $MSG = $COPY
            $FROM = GUICtrlRead($PATH1)
            $TO = GUICtrlRead($PATH2)
            $FILE = _FileListToArray($FROM)
            ProgressOn("","Copying",$FROM & " to " & $TO)
            For $INDEX = 1 To $FILE[0]
                FileCopy($FROM & "\" & $FILE[$INDEX],$TO & "\" & $FILE[$INDEX],1)
                ProgressSet($INDEX*100/Number($FILE[0]),$FROM & "\" & $FILE[$INDEX] & " to " & @CRLF & $TO & "\" & $FILE[$INDEX])
            Next
            ProgressOff()
        Case $MSG = -3
            Exit
    EndSelect
    Sleep(20)
WEnd

When the words fail... music speaks

Share this post


Link to post
Share on other sites

I rather like what Andreik created it looks clean and actually does not require me to have any dos file doing the actually copy/move in order to have a progress bar attached to it. But there is an Aesthetic look to it that does not bring out the best in what I created.

Was wondering if anyone or even you Andreik can help me to tweak my lil joy up a bit.

http://www.autoitscript.com/forum/index.ph...mp;#entry570395

(did not want to post it again, you can find it at another thread where it all started from.

Thanks.


Go farther, go further, Go Harder,Is that not why we came?And if not then why bother?

Share this post


Link to post
Share on other sites

this should have been placed in example scripts, not help and support :-)


global $warming = true

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