Jump to content

Dir Copy Pausing Script


Recommended Posts

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~~

Link to comment
Share on other sites

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...