Jump to content

Copy with progress dialog...


Recommended Posts

ok, then check out my try.

i took both of the script posted here, and worked on them, as i saw fit.

uses the same syntax, but with a custom made dialog, with avi, just like in windows.

i am certain someone can make a better one, this is my first script i post, but do check it out ;)

#CS
;~ This script is demonstrate copy process with custom designed progress displayed, the progress display details about the copy process.
;~ 
;~ Syntax: _CopyWithProgress("C:\Source", "C:\Dest", 1)
;~ First parm is the source dir that files will be copied from.
;~ Second param is the destination path that files will be copied to.
;~ If the last parameter set as 1, then all existing files will be replaced with copied ones.
;~ 
;~ Author: G.Sandler a.k.a CreatoR
;~ Functions _DirListToArray() and _FileListToArrayEx() is originaly writen by amel27.
;~ Further modded by damian666
#CE

#include <AVIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>

;_CopyWithProgress("C:\Source", "C:\Dest", 1)

Func _CopyWithProgress($SourcePath, $DestPath, $Replace=0)
    If Not FileExists($SourcePath) Then Return SetError(1, 0, -1)
    If Not StringInStr(FileGetAttrib($DestPath), "D") And Not DirCreate($DestPath) Then Return SetError(2, 0, "")
    If $Replace <> 0 And $Replace <> 1 Then SetError(3, 0, "")
    
    Local $PathName = StringRegExpReplace($SourcePath, "^.*\\", "")
    Local $Progress=0, $Counter, $ReadySize, $MidlePath, $Ready, $TimeRemained
    Local $CurrentFilePath, $CurrentFileName, $CurrentFilePathName, $CurrentParentDirName
    
;ProgressOn("Copy Files...", "Copy: " & $PathName, "Getting dir structure" & @LF & "Please wait...", -1, -1, 2 + 16)
    
    Local $TotalDirSize = DirGetSize($SourcePath)
    Local $FilesArr = _FileListToArrayEx($SourcePath)
    Local $FilesCount = UBound($FilesArr)-1
    Local $ProgressStep = 100 / $FilesCount
    
;testdialog
    Opt("GUIOnEventMode", 1)
    #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\Bureaublad\Form1.kxf
    $Form1 = GUICreate("Copying...", 401, 238, 193, 125, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
    $Avi1 = GUICtrlCreateAvi(@ScriptDir & "\160.avi", -1, 0, 0, 400, 56, BitOR($ACS_TRANSPARENT,$ACS_AUTOPLAY))
    $Progress1 = GUICtrlCreateProgress(8, 64, 385, 17)
    $Label1 = GUICtrlCreateLabel("From:", 8, 112, 36, 17)
    $Label2 = GUICtrlCreateLabel("", 56, 112, 338, 25)
    $Label3 = GUICtrlCreateLabel("Filecopy in progress...", 8, 88, 385, 17)
    $Label4 = GUICtrlCreateLabel("To:", 8, 152, 36, 17)
    $Label5 = GUICtrlCreateLabel("", 56, 151, 338, 25)
    $Button1 = GUICtrlCreateButton("Cancel", 337, 216, 59, 17, 0)
    GUICtrlSetOnEvent(-1, "Button1Click")
    $Label6 = GUICtrlCreateLabel("Approximately Remained Time:", 8, 184, 156, 17)
    $Label7 = GUICtrlCreateLabel("", 176, 184, 217, 17)
    $Label8 = GUICtrlCreateLabel("Already done:", 8, 208, 69, 17)
    $Label9 = GUICtrlCreateLabel("", 88, 208, 243, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    
;end testdialog
    
    If IsArray($FilesArr) Then
        For $i = 1 To UBound($FilesArr)-1
            $CurrentFilePath = $FilesArr[$i]
            $CurrentFileName = StringRegExpReplace($CurrentFilePath, "^.*\\", "")
            $CurrentFilePathName = StringReplace($CurrentFilePath, $SourcePath & "\", "")
            
            $CurrentParentDirName = _GetParentDirName($CurrentFilePath)
            
            $Progress += $ProgressStep
            $Counter += 1
            
            $ReadySize = FileGetSize($CurrentFilePath)
            
            $MidlePath = _GetMidlePath($CurrentFilePath)
            $Ready = $Counter & "/" & $FilesCount
            $TimeRemained = _GetTimeRemained($TotalDirSize, $ReadySize, $FilesCount, $Counter)
            
            GUICtrlSetData($Label2, $CurrentFilePath)
            GUICtrlSetData($Label5, $DestPath & "\" & $CurrentFilePathName)
            GUICtrlSetData($Progress1, $Progress)
            GUICtrlSetData($Label7, $TimeRemained)
            GUICtrlSetData($Label9, $Ready)
            
    ;ProgressSet($Progress, "Copy... from " & $CurrentParentDirName & " to " & $CurrentParentDirName & @LF & _
        ;$MidlePath & @LF & "Approximately Remained Time: " & $TimeRemained, "Ready: " & $Ready)
            FileCopy($CurrentFilePath, $DestPath & "\" & $CurrentFilePathName, 8+$Replace)
        Next
    EndIf
;ProgressOff()
EndFunc

Func _FileListToArrayEx($sPath, $sMask='*')
    Local $i, $j, $blist, $rlist[1]=[0], $dlist = _DirListToArray($sPath)
    _ArrayAdd ($dlist, $sPath)
    For $i=1 To $dlist [0] +1
        $blist = _FileListToArray ($dlist [$i], $sMask, 1)
        If Not @error Then
            For $j=1 To $blist [0]
                _ArrayAdd ($rlist, $dlist[$i] & "\" & $blist [$j])
            Next
        EndIf
    Next
    $rlist [0] = UBound ($rlist) - 1
    Return $rlist
EndFunc

Func _DirListToArray($sPath)
    Local $rlist[2]=[1, $sPath], $blist, $alist=_FileListToArray ($sPath, '*', 2)
    If IsArray ($alist) Then
        For $i=1 To $alist [0]
            _ArrayAdd ($rlist, $sPath & "\" & $alist [$i])
            $blist = _DirListToArray ($sPath & "\" & $alist [$i])
            If $blist[0]>0 Then
                For $j=1 To $blist [0]
                    _ArrayAdd ($rlist, $blist [$j])
                Next
            EndIf
        Next
    EndIf
    $rlist[0] = UBound($rlist) - 1
    Return $rlist
EndFunc

Func _GetMidlePath($sPath)
    If StringLen($sPath) <= 50 Then Return $sPath
    Local $StartPath = StringLeft($sPath, 25)
    Local $EndPath = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -2)-1)
    Return $StartPath & "..." & $EndPath
EndFunc

Func _GetParentDirName($FullName)
    Local $LastSlashPos = StringInStr($FullName, "\", 0, -1)
    Local $SecondLastSlashPos = StringInStr($FullName, "\", 0, -2)
    Return StringMid($FullName, $SecondLastSlashPos+1, $LastSlashPos-$SecondLastSlashPos-1)
EndFunc

Func _GetTimeRemained($TotalSize, $CurrentSize, $FilesCount, $CurrentFilesCount)
    Local $NumLevl = 0.5
    
    If $TotalSize <= $CurrentSize Then Return _SecsToTime(0)
    
    Switch $FilesCount - $CurrentFilesCount
        Case 0 To 100
            $NumLevl = 0.1
        Case 100 To 1000
            $NumLevl = 0.5
        Case 1000 to 2000
            $NumLevl = 1
        Case Else
            $NumLevl = 2
    EndSwitch
    
    $Secs = ($TotalSize * $NumLevl) / (3600 * $CurrentFilesCount) - ($CurrentSize * $NumLevl) / (3600 * $CurrentFilesCount)
    Return _SecsToTime($Secs)
EndFunc

Func _SecsToTime($iTicks, $Delim=":")
    If Number($iTicks) >= 0 Then
        $iHours = Int($iTicks / 3600)
        $iTicks = Mod($iTicks, 3600)
        $iMins = Int($iTicks / 60)
        $iSecs = Round(Mod($iTicks, 60))
        If StringLen($iHours) = 1 Then $iHours = "0" & $iHours
        If StringLen($iMins) = 1 Then $iMins = "0" & $iMins
        If StringLen($iSecs) = 1 Then $iSecs = "0" & $iSecs
        Return $iHours & $Delim & $iMins & $Delim & $iSecs
    EndIf
    Return SetError(1, 0, 0)
EndFunc

Func Button1Click()
    Exit
EndFunc

let me know what you think, oh and dont forget the avi in the same dir for now...

Damian666

F:\Program Files\AutoIt3\Include\ProgressConstants.au3 (16) : ==> Variable used without being declared.:

Global Const $PBM_SETRANGE = $WM_USER + 1

Global Const $PBM_SETRANGE = ^ ERROR

Website: www.cerescode.comForum: www.forum.cerescode.comIRC: irc.freenode.net , Channel: #Ceres--------------------Autoit Wrappers, Great additions to your script (Must See) (By: Valuater)Read It Befor Asking Question Click Here...--------------------Join Monoceres's Forums http://www.monoceres.se--------------------There are three kinds of people: Those who make things happen, those who watch things happen, and those who ask, ‘What happened?’” –Casey Stengel
Link to post
Share on other sites
  • Replies 69
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

This code copies a folder content in an other folder that have to exist already. It shows a progress dialog with percent completed (calculed over size) and a fraction of action done (calculated with

Posted Images

I get the following error when I try to run:

---------------------------

AutoIt Error

---------------------------

Line 90 (File "C:\Documents and Settings\Draygoes\Desktop\Test.au3"):

Local $sIstr, $bSF, $sCriteria, $sBuffer, $iH, $iH2, $sCS, $sCF, $sCF2, $sCP, $sFP, $sOutPut = '', $aNull[1]

Local ^ ERROR

Error: Can not redeclare a parameter inside a user function.

---------------------------

OK

---------------------------

This is the code that I used to test it...

DirCreate( @DesktopDir & "\user" )
_CopyDirWithProgress( @DesktopDir, @DesktopDir & "\user" )
Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to post
Share on other sites
  • 4 weeks later...

hey folks

I want to copy a single large file (e.g. 1GB) and show a progress bar for the copy process.

all of your scripts I tested only show the status of progress calculated by the number of files.

is there another solution for one single big file?

thanks for your help.

thomas

Edited by th0maz
Link to post
Share on other sites

In the german forum, theres a func in development, which uses a Copy function with callback :)

_MultiFileCopy It shows the Progress of all Files and the Progress of the current file.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to post
Share on other sites

hey folks

I want to copy a single large file (e.g. 1GB) and show a progress bar for the copy process.

all of your scripts I tested only show the status of progress calculated by the number of files.

is there another solution for one single big file?

thanks for your help.

thomas

Look here: http://www.autoitscript.com/forum/index.ph...ost&p=82020

Link to post
Share on other sites
  • 2 months later...

The UDF in the beginning of this thread works great however when it spawns off the copy progress window my autoit gui locks up (Not Responding) in vista. However the copy progress window does continue to copy and when it is done my GUI responds again. The problem is that my AutoIt GUI has a status bar that I have text in that says what is going on and when files/folders are being copied ect.. the text gets overlapped with the copy window.

Vista Ultimate SP1 ENG

AutoIt v3.2.13.8

Is this supposed to happen?

Thanks,

GoogleDude

Link to post
Share on other sites
  • 1 month later...

folder name current day.. :)

#CS
;~ This script is demonstrate copy process with custom designed progress displayed, the progress display details about the copy process.
;~ 
;~ Syntax: _CopyWithProgress("C:\Source", "C:\Dest", 1)
;~ First parm is the source dir that files will be copied from.
;~ Second param is the destination path that files will be copied to.
;~ If the last parameter set as 1, then all existing files will be replaced with copied ones.
;~ 
;~ Author: G.Sandler a.k.a CreatoR
;~ Functions _DirListToArray() and _FileListToArrayEx() is originaly writen by amel27.
#CE

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=..\..\..\WINDOWS\system32\RefreshLock.ico
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <File.au3>
#include <Date.au3>
$yedek = StringReplace(_NowTime(4),":","") &"_" &@MDAY &"-" &@MON &"-" &@YEAR
If Not @error Then DirCreate("c:\" &$yedek)

_CopyWithProgress("\\xxxpc\film\BIONİC WOMAN SEZON 1\bw.0106", "C:\" & $yedek, 1)

Func _CopyWithProgress($SourcePath, $DestPath, $Replace=0)
    If Not FileExists($SourcePath) Then Return SetError(1, 0, -1)
    If Not StringInStr(FileGetAttrib($DestPath), "D") And Not DirCreate($DestPath) Then Return SetError(2, 0, "")
    If $Replace <> 0 And $Replace <> 1 Then SetError(3, 0, "")
    
    Local $PathName = StringRegExpReplace($SourcePath, "^.*\\", "")
    Local $Progress=0, $Counter, $ReadySize, $MidlePath, $Ready, $TimeRemained
    Local $CurrentFilePath, $CurrentFileName, $CurrentFilePathName, $CurrentParentDirName
    
    ProgressOn("Copy Files...", "Copy: " & $PathName, "Getting dir structure" & @LF & "Please wait...")
    
    Local $TotalDirSize = DirGetSize($SourcePath)
    Local $FilesArr = _FileListToArrayEx($SourcePath)
    Local $FilesCount = UBound($FilesArr)-1
    Local $ProgressStep = 100 / $FilesCount
    
    If IsArray($FilesArr) Then
        For $i = 1 To UBound($FilesArr)-1
            $CurrentFilePath = $FilesArr[$i]
            $CurrentFileName = StringRegExpReplace($CurrentFilePath, "^.*\\", "")
            $CurrentFilePathName = StringReplace($CurrentFilePath, $SourcePath & "\", "")
            
            $CurrentParentDirName = _GetParentDirName($CurrentFilePath)
            
            $Progress += $ProgressStep
            $Counter += 1
            
            $ReadySize = FileGetSize($CurrentFilePath)
            
            $MidlePath = _GetMidlePath($CurrentFilePath)
            $Ready = $Counter & "/" & $FilesCount
            $TimeRemained = _GetTimeRemained($TotalDirSize, $ReadySize, $FilesCount, $Counter)
            
            ProgressSet($Progress, 'Copy... from "' & $CurrentParentDirName & '" to "' & $CurrentParentDirName & '"' & @LF & _
                $MidlePath & @LF & "Approximately Remained Time: " & $TimeRemained, "Ready: " & $Ready)
            FileCopy($CurrentFilePath, $DestPath & "\" & $CurrentFilePathName, 8+$Replace)
        Next
    EndIf
    ProgressOff()
EndFunc

Func _FileListToArrayEx($sPath, $sMask='*')
    Local $i, $j, $blist, $rlist[1]=[0], $dlist = _DirListToArray($sPath)
    _ArrayAdd ($dlist, $sPath)
    For $i=1 To $dlist [0] +1
        $blist = _FileListToArray ($dlist [$i], $sMask, 1)
        If Not @error Then
            For $j=1 To $blist [0]
                _ArrayAdd ($rlist, $dlist[$i] & "\" & $blist [$j])
            Next
        EndIf
    Next
    $rlist [0] = UBound ($rlist) - 1
    Return $rlist
EndFunc

Func _DirListToArray($sPath)
    Local $rlist[2]=[1, $sPath], $blist, $alist=_FileListToArray ($sPath, '*', 2)
    If IsArray ($alist) Then
        For $i=1 To $alist [0]
            _ArrayAdd ($rlist, $sPath & "\" & $alist [$i])
            $blist = _DirListToArray ($sPath & "\" & $alist [$i])
            If $blist[0]>0 Then
                For $j=1 To $blist [0]
                    _ArrayAdd ($rlist, $blist [$j])
                Next
            EndIf
        Next
    EndIf
    $rlist[0] = UBound($rlist) - 1
    Return $rlist
EndFunc

Func _GetMidlePath($sPath)
    If StringLen($sPath) <= 50 Then Return $sPath
    Local $StartPath = StringLeft($sPath, 25)
    Local $EndPath = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -2)-1)
    Return $StartPath & "..." & $EndPath
EndFunc

Func _GetParentDirName($FullName)
    Local $LastSlashPos = StringInStr($FullName, "\", 0, -1)
    Local $SecondLastSlashPos = StringInStr($FullName, "\", 0, -2)
    Return StringMid($FullName, $SecondLastSlashPos+1, $LastSlashPos-$SecondLastSlashPos-1)
EndFunc

Func _GetTimeRemained($TotalSize, $CurrentSize, $FilesCount, $CurrentFilesCount)
    Local $NumLevl = 0.5
    
    If $TotalSize <= $CurrentSize Then Return _SecsToTime(0)
    
    Switch $FilesCount - $CurrentFilesCount
        Case 0 To 100
            $NumLevl = 0.1
        Case 100 To 1000
            $NumLevl = 0.5
        Case 1000 to 2000
            $NumLevl = 1
        Case Else
            $NumLevl = 2
    EndSwitch
    
    $Secs = ($TotalSize * $NumLevl) / (3600 * $CurrentFilesCount) - ($CurrentSize * $NumLevl) / (3600 * $CurrentFilesCount)
    Return _SecsToTime($Secs)
EndFunc

Func _SecsToTime($iTicks, $Delim=":")
    If Number($iTicks) >= 0 Then
        $iHours = Int($iTicks / 3600)
        $iTicks = Mod($iTicks, 3600)
        $iMins = Int($iTicks / 60)
        $iSecs = Round(Mod($iTicks, 60))
        If StringLen($iHours) = 1 Then $iHours = "0" & $iHours
        If StringLen($iMins) = 1 Then $iMins = "0" & $iMins
        If StringLen($iSecs) = 1 Then $iSecs = "0" & $iSecs
        Return $iHours & $Delim & $iMins & $Delim & $iSecs
    EndIf
    Return SetError(1, 0, 0)
EndFunc
Link to post
Share on other sites
  • 1 month later...

ok, then check out my try.

i took both of the script posted here, and worked on them, as i saw fit.

uses the same syntax, but with a custom made dialog, with avi, just like in windows.

i am certain someone can make a better one, this is my first script i post, but do check it out :P

#CS
;~ This script is demonstrate copy process with custom designed progress displayed, the progress display details about the copy process.
;~ 
;~ Syntax: _CopyWithProgress("C:\Source", "C:\Dest", 1)
;~ First parm is the source dir that files will be copied from.
;~ Second param is the destination path that files will be copied to.
;~ If the last parameter set as 1, then all existing files will be replaced with copied ones.
;~ 
;~ Author: G.Sandler a.k.a CreatoR
;~ Functions _DirListToArray() and _FileListToArrayEx() is originaly writen by amel27.
;~ Further modded by damian666
#CE

let me know what you think, oh and dont forget the avi in the same dir for now...

Damian666

bit of amateurish coding, though.

i have made a small modification to include a splash screen that will display progress status because i was trying to test on a heavy folder and it was just silent

the user may not even know if the program has started working or not!!

#CS
;~  V1.1 16 Mar 2009 edited by Rajesh V R 
;~ Script modified to display current working folder - useful in time taking list to array process (for large directorylisting)

;~ This script is demonstrate copy process with custom designed progress displayed, the progress display details about the copy process.
;~
;~ Syntax: _CopyWithProgress("C:\Source", "C:\Dest", 1)
;~ First parm is the source dir that files will be copied from.
;~ Second param is the destination path that files will be copied to.
;~ If the last parameter set as 1, then all existing files will be replaced with copied ones.
;~
;~ Author: G.Sandler a.k.a CreatoR
;~ Functions _DirListToArray() and _FileListToArrayEx() is originaly writen by amel27.
;~ Further modded by damian666
#CE

#include <AVIConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>

_CopyWithProgress("C:\Program files\CustomPrograms\Imported\", "C:\Antivirus1", 1)

Func _CopyWithProgress($SourcePath, $DestPath, $Replace=0)
    If Not FileExists($SourcePath) Then Return SetError(1, 0, -1)
    If Not StringInStr(FileGetAttrib($DestPath), "D") And Not DirCreate($DestPath) Then Return SetError(2, 0, "")
    If $Replace <> 0 And $Replace <> 1 Then SetError(3, 0, "")
    
    Local $PathName = StringRegExpReplace($SourcePath, "^.*\\", "")
    Local $Progress=0, $Counter, $ReadySize, $MidlePath, $Ready, $TimeRemained
    Local $CurrentFilePath, $CurrentFileName, $CurrentFilePathName, $CurrentParentDirName
    
;ProgressOn("Copy Files...", "Copy: " & $PathName, "Getting dir structure" & @LF & "Please wait...", -1, -1, 2 + 16)
    
    Local $tmpFileTag, $tmpDirTag
    SplashTextOn("Initialising FileOperation Sequence...","",400,150,-1,-1, 4+16,"Arial",9)
        
    Local $TotalDirSize = DirGetSize($SourcePath)
    Local $FilesArr = _FileListToArrayEx($SourcePath)
    Local $FilesCount = UBound($FilesArr)-1
    Local $ProgressStep = 100 / $FilesCount
    
    SplashOff()
        
;testdialog
    Opt("GUIOnEventMode", 1)
    #Region ### START Koda GUI section ### Form=C:\Documents and Settings\Administrator\Bureaublad\Form1.kxf
    $Form1 = GUICreate("Copying...", 401, 238, 193, 125, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
    $Avi1 = GUICtrlCreateAvi(@ScriptDir & "\160.avi", -1, 0, 0, 400, 56, BitOR($ACS_TRANSPARENT,$ACS_AUTOPLAY))
    $Progress1 = GUICtrlCreateProgress(8, 64, 385, 17)
    $Label1 = GUICtrlCreateLabel("From:", 8, 112, 36, 17)
    $Label2 = GUICtrlCreateLabel("", 56, 112, 338, 25)
    $Label3 = GUICtrlCreateLabel("Filecopy in progress...", 8, 88, 385, 17)
    $Label4 = GUICtrlCreateLabel("To:", 8, 152, 36, 17)
    $Label5 = GUICtrlCreateLabel("", 56, 151, 338, 25)
    $Button1 = GUICtrlCreateButton("Cancel", 337, 216, 59, 17, 0)
    GUICtrlSetOnEvent(-1, "Button1Click")
    $Label6 = GUICtrlCreateLabel("Approximately Remained Time:", 8, 184, 156, 17)
    $Label7 = GUICtrlCreateLabel("", 176, 184, 217, 17)
    $Label8 = GUICtrlCreateLabel("Already done:", 8, 208, 69, 17)
    $Label9 = GUICtrlCreateLabel("", 88, 208, 243, 17)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    
;end testdialog
    
    If IsArray($FilesArr) Then
        For $i = 1 To UBound($FilesArr)-1
            $CurrentFilePath = $FilesArr[$i]
            $CurrentFileName = StringRegExpReplace($CurrentFilePath, "^.*\\", "")
            $CurrentFilePathName = StringReplace($CurrentFilePath, $SourcePath & "\", "")
            
            $CurrentParentDirName = _GetParentDirName($CurrentFilePath)
            
            $Progress += $ProgressStep
            $Counter += 1
            
            $ReadySize = FileGetSize($CurrentFilePath)
            
            $MidlePath = _GetMidlePath($CurrentFilePath)
            $Ready = $Counter & "/" & $FilesCount
            $TimeRemained = _GetTimeRemained($TotalDirSize, $ReadySize, $FilesCount, $Counter)
            
            GUICtrlSetData($Label2, $CurrentFilePath)
            GUICtrlSetData($Label5, $DestPath & "\" & $CurrentFilePathName)
            GUICtrlSetData($Progress1, $Progress)
            GUICtrlSetData($Label7, $TimeRemained)
            GUICtrlSetData($Label9, $Ready)
            
   ;ProgressSet($Progress, "Copy... from " & $CurrentParentDirName & " to " & $CurrentParentDirName & @LF & _
       ;$MidlePath & @LF & "Approximately Remained Time: " & $TimeRemained, "Ready: " & $Ready)
            FileCopy($CurrentFilePath, $DestPath & "\" & $CurrentFilePathName, 8+$Replace)
        Next
    EndIf
;ProgressOff()
EndFunc

Func _FileListToArrayEx($sPath, $sMask='*')
        
    _SetSplash($sPath,"_FileListToArrayEx","")
    
    Local $i, $j, $blist, $rlist[1]=[0], $dlist = _DirListToArray($sPath)
    
    
        _ArrayAdd ($dlist, $sPath)
        
        For $i=1 To $dlist [0] +1
            $blist = _FileListToArray ($dlist[$i], $sMask, 1)
            If Not @error Then
                For $j=1 To $blist [0]
                    _SetSplash($dlist[$i], "_FileListToArray", $j  )
                    _ArrayAdd ($rlist, $dlist[$i] & "\" & $blist [$j])
                    _SetSplash($dlist[$i], "_FileListToArray", $j  )
                Next
            EndIf
        Next
        $rlist [0] = UBound ($rlist) - 1
    
    

    Return $rlist
        
EndFunc

Func _DirListToArray($sPath)
    _SetSplash($sPath,"_DirListToArray","")
    
    Local $rlist[2]=[1, $sPath], $blist, $alist=_FileListToArray ($sPath, '*', 2)

    If IsArray ($alist) Then
        For $i=1 To $alist [0]
            _ArrayAdd ($rlist, $sPath & "\" & $alist [$i])
            $blist = _DirListToArray ($sPath & "\" & $alist [$i])
            If $blist[0]>0 Then
                For $j=1 To $blist [0]
                   _SetSplash($sPath, "_DirListToArray",$j )
                    _ArrayAdd ($rlist, $blist [$j])
                   _SetSplash($sPath, "_DirListToArray",$j )
                Next
            EndIf
        Next
    EndIf
    
    $rlist[0] = UBound($rlist) - 1
    
        
    Return $rlist
EndFunc

Func _GetMidlePath($sPath)
    If StringLen($sPath) <= 50 Then Return $sPath
    Local $StartPath = StringLeft($sPath, 25)
    Local $EndPath = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -2)-1)
    Return $StartPath & "..." & $EndPath
EndFunc

Func _GetParentDirName($FullName)
    Local $LastSlashPos = StringInStr($FullName, "\", 0, -1)
    Local $SecondLastSlashPos = StringInStr($FullName, "\", 0, -2)
    Return StringMid($FullName, $SecondLastSlashPos+1, $LastSlashPos-$SecondLastSlashPos-1)
EndFunc

Func _GetTimeRemained($TotalSize, $CurrentSize, $FilesCount, $CurrentFilesCount)
    Local $NumLevl = 0.5
    
    If $TotalSize <= $CurrentSize Then Return _SecsToTime(0)
    
    Switch $FilesCount - $CurrentFilesCount
        Case 0 To 100
            $NumLevl = 0.1
        Case 100 To 1000
            $NumLevl = 0.5
        Case 1000 to 2000
            $NumLevl = 1
        Case Else
            $NumLevl = 2
    EndSwitch
    
    $Secs = ($TotalSize * $NumLevl) / (3600 * $CurrentFilesCount) - ($CurrentSize * $NumLevl) / (3600 * $CurrentFilesCount)
    Return _SecsToTime($Secs)
EndFunc

Func _SecsToTime($iTicks, $Delim=":")
    If Number($iTicks) >= 0 Then
        $iHours = Int($iTicks / 3600)
        $iTicks = Mod($iTicks, 3600)
        $iMins = Int($iTicks / 60)
        $iSecs = Round(Mod($iTicks, 60))
        If StringLen($iHours) = 1 Then $iHours = "0" & $iHours
        If StringLen($iMins) = 1 Then $iMins = "0" & $iMins
        If StringLen($iSecs) = 1 Then $iSecs = "0" & $iSecs
        Return $iHours & $Delim & $iMins & $Delim & $iSecs
    EndIf
    Return SetError(1, 0, 0)
EndFunc

Func Button1Click()
    Exit
EndFunc

Func _GetNameFromPath($FullPath)

; created 30 Dec 2008
; Purpose : Get File Name only from a full path given
; Usage: GetNameFromPath(Full File name with path) will return only the file or folder name at the end 

    Local $DirLen , $FindSlash, $FName

; Clear Trailing Slash "\" 
    If StringRight($FullPath,1) = "\" Then $FullPath = StringTrimRight($FullPath,1)

    $DirLen = StringLen($FullPath)

    $FindSlash = StringInStr( $FullPath, "\" ,0 , -1 )
        
    $FName = StringRight($FullPath ,$DirLen - $FindSlash)
    
    IF @ERROR Then Exit

    Return $FName 

EndFunc


Func _SetSplash($tmpDir,$callerID,$varLoop)
    Local $Message = "", $Module 

    If $callerID = "_DirListToArray" Then 
        $callerID = "Processing directories....." 
    Else 
        $CallerID = "Processing files....." 
    EndIf
    
;$Message = $Message & "Source: " & $Sourcepath
    $Message = $Message & $callerID & @CRLF & @CRLF 
    $Message = $Message & "Folder: "& _GetParentDirName($tmpDir) & @CRLF & @CRLF 
    $Message = $Message & "Processing:" & _GetNameFromPath($tmpDir) & @CRLF & @CRLF 
    If $varLoop > 10 Then  $VarLoop = Mod ($VarLoop,10)
    $Message = $Message & _ShowChars("*",$varLoop)

    ControlSetText("Initialising FileOperation Sequence...", "", "Static1", $Message )
EndFunc 

Func _ShowChars($char,$Count)
    Local $x , $tmpChar
    
    Switch $Count 
        
        Case 0 
            $tmpchar =  ""
        Case 1 
            $tmpchar =  ""
        Case Else 
            For $x = 0 to $Count -1
                $tmpchar = $tmpChar & $char & $char 
            Next 
        EndSwitch
    Return $tmpchar
EndFunc

i have used splash screen If a seperate GUI can be created that might be good as well (in case some module calling this function is already using a splash text !)

Link to post
Share on other sites

folder name current day.. :P

#CS
;~ This script is demonstrate copy process with custom designed progress displayed, the progress display details about the copy process.
;~ 
;~ Syntax: _CopyWithProgress("C:\Source", "C:\Dest", 1)
;~ First parm is the source dir that files will be copied from.
;~ Second param is the destination path that files will be copied to.
;~ If the last parameter set as 1, then all existing files will be replaced with copied ones.
;~ 
;~ Author: G.Sandler a.k.a CreatoR
;~ Functions _DirListToArray() and _FileListToArrayEx() is originaly writen by amel27.
#CE

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=..\..\..\WINDOWS\system32\RefreshLock.ico
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
#include <File.au3>
#include <Date.au3>
$yedek = StringReplace(_NowTime(4),":","") &"_" &@MDAY &"-" &@MON &"-" &@YEAR
If Not @error Then DirCreate("c:\" &$yedek)

_CopyWithProgress("\\xxxpc\film\BIONİC WOMAN SEZON 1\bw.0106", "C:\" & $yedek, 1)

Man!

i missed this earlier, this is the reason i am here loooking for a progress bar copier,, my friend has a lot of file he downloaded from internet and they were to be organised in folders i would first try to use my own coding but this is good lemme try it out :-)

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...