YoseMite Posted February 21, 2006 Share Posted February 21, 2006 Hi, I working on a simple dir copy script, but I've 2 questions about it. 1. I want copy all files to the root, and every file that exist must me overwrite, how must I do this? (I has searching on this forum but I can't find that work.) 2. I now how onprogress() work with download files from the internet, but how must I do this with dircopy? I now that you must have the size of the dir and the copy speed, but what is the copy speed? Anyway thanks for reading. YoseMite Link to comment Share on other sites More sharing options...
BigDod Posted February 21, 2006 Share Posted February 21, 2006 Hi, I working on a simple dir copy script, but I've 2 questions about it. 1. I want copy all files to the root, and every file that exist must me overwrite, how must I do this? (I has searching on this forum but I can't find that work.) 2. I now how onprogress() work with download files from the internet, but how must I do this with dircopy? I now that you must have the size of the dir and the copy speed, but what is the copy speed? Anyway thanks for reading. YoseMiteAnswer to part 1, straight from help files. DirCopy("C:\My Documents", "C:\Backups\MyDocs", 1) Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Nuffilein805 Posted February 21, 2006 Share Posted February 21, 2006 i don't get your 2nd question, maybe you could clarify it a bit so even i do understand it my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
YoseMite Posted February 21, 2006 Author Share Posted February 21, 2006 (edited) ah al right... I see that question 1 works... Allright I explain 2nd question. You have a folder: C:\dir With different files and folders on it. (50MB) Now I want copy this to the C:\ Now I want make a progress % for copying the dir C:\dir to C:\. Do you get it? :$ Edited February 21, 2006 by YoseMite Link to comment Share on other sites More sharing options...
BigDod Posted February 21, 2006 Share Posted February 21, 2006 Checkout This topic. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
ChrisL Posted February 21, 2006 Share Posted February 21, 2006 ah al right... I see that question 1 works... Allright I explain 2nd question. You have a folder: C:\dir With different files and folders on it. (50MB) Now I want copy this to the C:\ Now I want make a progress % for copying the dir C:\dir to C:\. Do you get it? :$ Can you use or modify this? expandcollapse popup#include <GUIConstants.au3> Global $Run1 = 0, $tosearch, $OverallQty, $Overall, $source, $overallpercent, $Progress0Text, $progressbar1, $Progress1Text, $progressbar2, $Progress2Text, $Gui ProgressCopy("C:\MyFolderFullOfFiles", "D:\MyNewFolder") Func ProgressCopy($current, $destination) ;FirstTimeRun Get original DirSize and set up Gui If $Run1 = 0 Then If not FileExists ($Destination) then DirCreate ($Destination); This is why it was failing, the dir did not exist $source = $current If StringRight($current, 1) = '\' Then $current = StringTrimRight($current, 1) If StringRight($destination, 1) <> '\' Then $destination = $destination & "\" $tosearch = $current $Overall = DirGetSize($tosearch, 1) $OverallQty = $Overall[1] $Gui = GUICreate("Copying Files", 420, 100, -1, -1, -1, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST) $Progress0Text = GUICtrlCreateLabel("Please Wait", 10, 5, 400, 20, $SS_LEFTNOWORDWRAP) $progressbar1 = GUICtrlCreateProgress(10, 20, 400, 20) GUICtrlSetColor(-1, 32250) $Progress1Text = GUICtrlCreateLabel("", 10, 44, 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 if not using windows classic style GUISetState(@SW_SHOW) GUICtrlSetData($Progress1Text, "Working Directory " & $tosearch) $Run1 = 1 EndIf $Size = DirGetSize($current, 3) $Qty = $Size[1] Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then $Qty -= 1 $LocalPercent = 100 - (($Qty / $Size[1]) * 100) $OverallQty -= 1 $overallpercent = 100 - (($OverallQty / $Overall[1]) * 100) GUICtrlSetData($Progress0Text, "Total Progress " & Int($overallpercent) & "% completed") GUICtrlSetData($progressbar1, $overallpercent) GUICtrlSetData($progressbar2, $LocalPercent) GUICtrlSetData($Progress2Text, "Copying File " & $file) FileCopy($current & "\" & $file, $destination & StringTrimLeft($current, StringLen($source)) & "\" & $file) FileSetAttrib($destination & StringTrimLeft($current, StringLen($source)) & "\" & $file, "-R") EndIf If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then DirCreate($destination & StringTrimLeft($current, StringLen($source)) & "\" & $file) FileSetAttrib($destination & StringTrimLeft($current, StringLen($source)) & "\" & $file, "-R") GUICtrlSetData($Progress1Text, $current & "\" & $file) ProgressCopy($current & "\" & $file, $destination) EndIf WEnd FileClose($search) ;when overall percent = 100 set end gui text, delete gui and reset run1 to 0 If $overallpercent = 100 Then GUICtrlSetData($Progress0Text, "Total Progress 100% completed") GUICtrlSetData($progressbar1, 100) GUICtrlSetData($progressbar2, 100) GUICtrlSetData($Progress2Text, "Done!") Sleep(2000) GUIDelete($Gui) $Run1 = 0 EndIf EndFunc ;==>ProgressCopy [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...
YoseMite Posted February 21, 2006 Author Share Posted February 21, 2006 Thanks alot ChrisL! That is what I need! Link to comment Share on other sites More sharing options...
YoseMite Posted February 21, 2006 Author Share Posted February 21, 2006 I've got some overwrite problems with your script... Link to comment Share on other sites More sharing options...
ChrisL Posted February 21, 2006 Share Posted February 21, 2006 I've got some overwrite problems with your script... Do you want to be a little more specific [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...
YoseMite Posted February 21, 2006 Author Share Posted February 21, 2006 The script overwrite not a new file... I've changed a file from C:\dir and I copy this to D:\ but he doesn't "update" the file... Do you get? :$ Link to comment Share on other sites More sharing options...
ChrisL Posted February 21, 2006 Share Posted February 21, 2006 (edited) you mean it doesn't overwrite a file if it already exists? Stick ,1 at the end of the FileCopy line as below FileCopy($current & "\" & $file, $destination & StringTrimLeft($current, StringLen($source)) & "\" & $file,1) You need to use one of the beta versions, but quite an old beta will work, the release AutoIT goes a bit funny! Edited February 21, 2006 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...
YoseMite Posted February 21, 2006 Author Share Posted February 21, 2006 Ah, I see it! Thanks, my Enlish is not very good, but you understand me:) Thanks anyway, 2 questions are now clear! 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