ChrisL Posted September 21, 2005 Share Posted September 21, 2005 (edited) This seems to work OK, if you compile it you can run it from a command prompt or send the parrameters to the StartCopy function, Thanks to Lxp who did some of the original code for another project. expandcollapse popup#include <file.au3> Global $FileCount = 0 Global $FirstRunCount=0 Global $FileCount = 0 Global $QtyLeft=0 ;StartCopy ("D:\Kiosk" , "D:\Kiosk2\") If $cmdline[0] = 2 Then $DirSearch = $cmdline[1] $Destination = $cmdline[2] StartCopy ($DirSearch,$Destination) Else ;MsgBox(0,'Invalid # of parameters!',$cmdline[0]&' is an Invalid number of parameters.') ;Exit EndIf Func StartCopy ($Var1, $Var2) If StringRight($Var1, 1) = '\' Then $Var1 = StringtrimRight( $Var1, 1 ) If StringRight($Var2, 1) <> '\' Then $Var2 = $Var2 & '\' $Var3 = $Var1 ProgressOn ("Copying Files", " Please Wait: Copying: " , "To ", -1,-1,16 ) processFolder($Var1, $Var2, $Var3) debug ("Total Files Counted " & $FileCount) $QtyLeft = $FileCount $FirstRunCount=1 ProcessFolder ($Var1, $Var2, $Var3) ProgressOff() EndFunc func processFolder($path, $Destination, $Fixed) local $fileHandle, $file, $dirHandle, $dir local const $FILESPEC = "*.*" debug("Starting with " & $path) debug("Going to search for " & $path & "\" & $FILESPEC) $fileHandle = fileFindFirstFile($path & "\" & $FILESPEC) if ($fileHandle <> -1) then while (1) $file = fileFindNextFile($fileHandle) if (@error = 1) then exitLoop if ($file = "." or $file = "..") then continueLoop $file = $path & "\" & $file if (isFolder($file,$Destination, $Fixed)) then continueLoop copy($file, $Destination, $Fixed) wEnd fileClose($fileHandle) endIf debug("Going to search for subfolders") $dirHandle = fileFindFirstFile($path & "\*.*") if ($dirHandle <> -1) then while (1) $dir = fileFindNextFile($dirHandle) if (@error = 1) then exitLoop if ($dir = "." or $dir = "..") then continueLoop $dir = $path & "\" & $dir if (not(isFolder($dir,$Destination, $Fixed))) then continueLoop debug("Found subfolder " & $dir) processFolder($dir, $Destination, $Fixed) wEnd fileClose($dirHandle) endIf endFunc func isFolder($path,$Destination, $Fixed) if stringInStr(fileGetAttrib($path), "D") then $stripped =stringreplace($Path, $Fixed &"\","") DirCreate ( $Destination & $Stripped ) debug ("Path " & $Path) debug ("Creat Dir " & $Destination & $Stripped) return 1 else Endif return 0 endFunc func copy($text,$Destination, $Fixed) $NewDir = $Destination $stripped =stringreplace($text, $fixed &"\","") if $FirstRunCount = 0 then $FileCount = $FileCount + 1 Else FileCopy ($text, $NewDir & $Stripped,1) $QtyLeft = $QtyLeft - 1 $Percent = $qtyLeft * 100 / $FileCount $Percent1 = 100 - $Percent ProgressSet ( $Percent1 + 1 ,"Copying " & $text & @CRLF & @CRLF & "To " & $NewDir & $Stripped , " Please Wait: " ) Endif endFunc func debug($text) ;msgBox(0x40, "", $text) endFunc Edited September 21, 2005 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
ChrisL Posted September 22, 2005 Author Share Posted September 22, 2005 I modified it.... expandcollapse popup#include <file.au3> #include <Array.au3> #include <GUIConstants.au3> ; Script Start - Add your code below here GUICreate("Copying Files",420,100, -1,-1,-1, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) $progressbar1 = GUICtrlCreateProgress (10,20,400,20) GUICtrlSetColor(-1,32250) $Progress1Text = GUICtrlCreateLabel ( "Checking Files ", 10, 42 , 400 , 20, $SS_LEFTNOWORDWRAP ) $progressbar2 = GUICtrlCreateProgress (10,60,400,20, $PBS_SMOOTH, ) $Progress2Text = GUICtrlCreateLabel ( "", 10, 82 , 400 , 20, $SS_LEFTNOWORDWRAP ) GUISetFont (10, 600, ) $Progress2Text2 = GUICtrlCreateLabel ( "", 150, 62 , 400 , 20 ) GUICtrlSetColor(-1,0xffffff); not working with Windows XP Style GUISetState (@SW_Show) Global $FileCount = 0 Global $FirstRunCount=0 Global $QtyLeft=0 Global $CountFilesInCurrent=0 Global $Count2 Global $CurrentDirQty Global $Percent2 ;StartCopy ("D:\Kiosk" , "D:\Kiosk2\") If $cmdline[0] = 2 Then $DirSearch = $cmdline[1] $Destination = $cmdline[2] StartCopy ($DirSearch,$Destination) Else ;MsgBox(0,'Invalid # of parameters!',$cmdline[0]&' is an Invalid number of parameters.') ;Exit EndIf Func StartCopy ($Var1, $Var2) If StringRight($Var1, 1) = '\' Then $Var1 = StringtrimRight( $Var1, 1 ) If StringRight($Var2, 1) <> '\' Then $Var2 = $Var2 & '\' $Var3 = $Var1 ;ProgressOn ("Copying Files", " Please Wait: Copying: " , "To ", -1,-1,16 ) processFolder($Var1, $Var2, $Var3) debug ("Total Files Counted " & $FileCount) $QtyLeft = $FileCount $FirstRunCount=1 ProcessFolder ($Var1, $Var2, $Var3) ;ProgressOff() GUICtrlSetData ( $Progress1Text, "Complete" ) GUICtrlSetData ($progressbar2, 100) GUICtrlSetData ( $Progress2Text, "Complete" ) GUICtrlSetData ( $Progress2Text2, "Total Progress 100%") Sleep (1000) EndFunc func processFolder($path, $Destination, $Fixed) local $fileHandle, $file, $dirHandle, $dir local const $FILESPEC = "*.*" debug("Starting with " & $path) $FirstCountFilesInCurrent = 0 $Count2 = 1 debug("Going to search for " & $path & "\" & $FILESPEC) $fileHandle = fileFindFirstFile($path & "\" & $FILESPEC) if ($fileHandle <> -1) then If $FirstRunCount = 1 then Count($Path) endif while (1) $file = fileFindNextFile($fileHandle) if (@error = 1) then exitLoop if ($file = "." or $file = "..") then continueLoop $file = $path & "\" & $file if (isFolder($file,$Destination, $Fixed)) then continueLoop copy($file, $Destination, $Fixed) If $FirstRunCount = 0 then $FirstCountFilesInCurrent = $FirstCountFilesInCurrent + 1 wEnd fileClose($fileHandle) endIf debug("Going to search for subfolders") $dirHandle = fileFindFirstFile($path & "\*.*") if ($dirHandle <> -1) then while (1) $dir = fileFindNextFile($dirHandle) if (@error = 1) then exitLoop if ($dir = "." or $dir = "..") then continueLoop $dir = $path & "\" & $dir if (not(isFolder($dir,$Destination, $Fixed))) then continueLoop debug("Found subfolder " & $dir) processFolder($dir, $Destination, $Fixed) ;$CountFilesInCurrent = 1 $CurrentPercent = 0 wEnd fileClose($dirHandle) endIf endFunc func isFolder($path,$Destination, $Fixed) if stringInStr(fileGetAttrib($path), "D") then $stripped =stringreplace($Path, $Fixed &"\","") DirCreate ( $Destination & $Stripped ) debug ("Path " & $Path) debug ("Creat Dir " & $Destination & $Stripped) return 1 else Endif return 0 endFunc func copy($text,$Destination, $Fixed) $NewDir = $Destination $stripped =stringreplace($text, $fixed &"\","") if $FirstRunCount = 0 then $FileCount = $FileCount + 1 Else Progress ($CurrentDirQty, $Count2) $QtyLeft = $QtyLeft - 1 $Percent = $qtyLeft * 100 / $FileCount $Percent1 = 100 - $Percent $Count2 = $Count2 + 1 ;ProgressSet ( $Percent1 + 1 ,"Copying " & $text & @CRLF & @CRLF & "To " & $NewDir & $Stripped , " Please Wait: " ) $aWholeNumber2 = StringSplit( $Percent2, "." ) ;_arrayDisplay ( $aWholeNumber2, "") GUICtrlSetData ( $Progress1Text, $aWholeNumber2[1] & "% of Current Folder:- " & $Stripped ) $aWholeNumber = StringSplit( $Percent1, "." ) ;_arrayDisplay ( $aWholeNumber, "") GUICtrlSetData ($progressbar2,$Percent1) GUICtrlSetData ( $Progress2Text, $NewDir & $Stripped ) GUICtrlSetData ( $Progress2Text2, "Total Progress " & $AWholeNumber[1] & "%" ) FileCopy ($text, $NewDir & $Stripped,1) Endif endFunc Func Count($Dir) local $fileHandle, $File, $Path, $Destination , $Fixed, $Count2 $fileHandle = fileFindFirstFile($Dir & "\" & "*.*") if ($fileHandle <> -1) then while (1) $file = fileFindNextFile($fileHandle) if (@error = 1) then exitLoop if ($file = "." or $file = "..") then continueLoop $file = $path & "\" & $file $Count2 = $Count2 + 1 wend fileClose($FileHandle) Endif $CurrentDirQty = $Count2 Endfunc func debug($text) ;If $FirstRunCount = 1 then msgBox(0x40, "", $text) endFunc Func Progress($CurrentDirQty, $Count2 ) $QtyLeft2 = $Count2 + 1 $QtyLeft2 = $QtyLeft2 - 1 $Percent2 = $qtyLeft2 * 100 / $CurrentDirQty GUICtrlSetData ($progressbar1,$Percent2) EndFunc [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now