Sign in to follow this  
Followers 0
Normonator

Dir Copy Pausing Script

4 posts in this topic

I made a script backup program to backup my scripts folder from my flash drive to a folder on a desktop, etc. but i wanted to add a progress bar so you can see how far it is. but when i run this script the dircopy function pauses the script and doesn't set the progress until it's already done.

If anybody has a solution to this problem it'd be a huge help

Thanks heres my script:

$dir = FileSelectFolder('Choose Your Backup Location:','')
If @error = 1 Then
    MsgBox(48,"Backup",'Backup Canceled!')
    Exit
Else
    AdlibRegister('_prog')
    ProgressOn('Script Backup','Working...')
$conf=_copy ()
        If $conf = 1 then

            MsgBox(48,"Backup",'Backup Complete!')
        Else
            MsgBox(48,"Backup",'Backup Failed!')
        EndIf
        ProgressOff()
    Exit
EndIf

While True
WEnd
Func _prog ()
    $orig = DirGetSize(@ScriptDir & '\scripts')/1024^2
    $new = DirGetSize($dir)/1024^2
    $prog = $new / $orig *100
    ProgressSet($prog)
EndFunc
Func _copy ()
    Return DirCopy('\scripts',$dir,1)
EndFunc

[member='That Guy']~~Normonator~~

Share this post


Link to post
Share on other sites



DirCopy() is a blocking function, it waits for the result to return. Search the examples forum for a FileListToArray() UDF and combine that with FileCopy(,8).

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I made a script backup program to backup my scripts folder from my flash drive to a folder on a desktop, etc. but i wanted to add a progress bar so you can see how far it is. but when i run this script the dircopy function pauses the script and doesn't set the progress until it's already done.

If anybody has a solution to this problem it'd be a huge help

Thanks heres my script:

My script:

#include <File.au3>

$dir = FileSelectFolder('Choose Your Backup Location:','')
$pathlen = StringLen($dir)
If @error = 1 Then
    MsgBox(48,"Backup",'Backup Canceled!')
    Exit
Else
    AdlibRegister('_prog')
    ProgressOn('Script Backup','Working...')
    $conf=_copy ($dir)
    If $conf = 1 then
        MsgBox(48,"Backup",'Backup Complete!')
    Else
        MsgBox(48,"Backup",'Backup Failed!')
    EndIf
    ProgressOff()
    Exit
EndIf

While True
WEnd

Func _prog ()
    $orig = DirGetSize(@ScriptDir & '\scripts')/1024^2
    $new = DirGetSize($dir)/1024^2
    $prog = $new / $orig *100
    ProgressSet($prog)
EndFunc

Func _copy($_Path)
    $folder = _FileListToArray($_Path, "*", 0)
    If Not IsArray($folder) Then Return 0
    For $o = 1 To $folder[0]
        _copy($_Path & "\" & $folder[$o])
        FileCopy ($_Path, @ScriptDir & '\scripts\'&StringTrimLeft($_Path,$pathlen)&"\",9)
    Next
    Return 1
EndFunc
Edited by cln

Share this post


Link to post
Share on other sites

Wow thanks for the help. So now that that works could any of you tell me how i can set a restore function to fade transparency in?


[member='That Guy']~~Normonator~~

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