buzz44 Posted January 5, 2005 Share Posted January 5, 2005 (edited) hey everyonE, made this yesterday it copies a file from one place to another showing a progress bar. features: > use GUI folder secect > MAke new folder option > > shows progress Bar > Displayed percented and Mb copied > Tell's you if the files were moved successfully or if they werent and how much Mb of the file did copy successfully enjoy expandcollapse popup$origdirect = FileSelectFolder("Please select the folder you wish to backup.", "") If @error = 1 Then Exit Else $copydirect = FileSelectFolder("Where would you like to backup this folder to.", "", 1) If @error = 1 Then Exit Else CopyFolder($origdirect, $copydirect) EndIf EndIf Func CopyFolder($Folder1, $Folder2) Local $ProcID $ProcID = Run(@ComSpec & ' /c xcopy /e /h /y "' & $Folder1 & '" "' & $Folder2 & '"', "", @SW_HIDE) ProgressOn("Progress Meter", "") $origfilesize = DirGetSize($Folder1) Do $copyfilesize = DirGetSize($Folder2) $MBcopy = dirGetSize($Folder2) / 1024 / 1024 $percent = $copyfilesize / $origfilesize * 100 $decimalplace = Round ($percent) $decimalplaceMBcopy = Round ($MBcopy) ProgressSet ($percent, $decimalplace & "% " & "(" & _ $decimalplaceMBcopy & ") Mb has been copied.") Sleep(500) Until NOT ProcessExists($ProcID) ProgressOff () $copyfilesize = DirGetSize($Folder2) $MBorig = dirGetSize($Folder1) / 1024 / 1024 $decimalplaceMBorig = Round ($MBorig) If $origfilesize = $copyfilesize then Msgbox(0,"Backup Complete", "All " & $decimalplaceMBcopy & " Mb of files and folders were copied successfully.") Else Msgbox(0,"Error", "The backup did not complete successfully. Only " & $decimalplaceMBcopy & " Mb of " & $decimalplaceMBorig & " Mb copied successfully.") EndIf EndFunc Edit: ive updated the code, it now used a GUI folder select Otion, GUI make new folder, thx go out to slimshady for helping me get the variable copyfolder function 60+ views and no replys??, does sum1 wanna leave sum feedback plz Edited January 6, 2005 by burrup qq Link to comment Share on other sites More sharing options...
DirtyBanditos Posted January 6, 2005 Share Posted January 6, 2005 (edited) hey everyonE, made this yesterday it copies a file from one place to another showing a progress bar.features:> use GUI folder secect> MAke new folder option> > shows progress Bar> Displayed percented and Mb copied> Tell's you if the files were moved successfully or if they werent and how much Mb of the file did copy successfullyenjoyexpandcollapse popup$origdirect = FileSelectFolder("Please select the folder you wish to backup.", "") If @error = 1 Then Exit Else $copydirect = FileSelectFolder("Where would you like to backup this folder to.", "", 1) If @error = 1 Then Exit Else CopyFolder($origdirect, $copydirect) EndIf EndIf Func CopyFolder($Folder1, $Folder2) Local $ProcID $ProcID = Run(@ComSpec & ' /c xcopy /e /h /y "' & $Folder1 & '" "' & $Folder2 & '"', "", @SW_HIDE) ProgressOn("Progress Meter", "") $origfilesize = DirGetSize($Folder1) Do $copyfilesize = DirGetSize($Folder2) $MBcopy = dirGetSize($Folder2) / 1024 / 1024 $percent = $copyfilesize / $origfilesize * 100 $decimalplace = Round ($percent) $decimalplaceMBcopy = Round ($MBcopy) ProgressSet ($percent, $decimalplace & "% " & "(" & _ $decimalplaceMBcopy & ") Mb has been copied.") Sleep(500) Until NOT ProcessExists($ProcID) ProgressOff () $copyfilesize = DirGetSize($Folder2) $MBorig = dirGetSize($Folder1) / 1024 / 1024 $decimalplaceMBorig = Round ($MBorig) If $origfilesize = $copyfilesize then Msgbox(0,"Backup Complete", "All " & $decimalplaceMBcopy & " Mb of files and folders were copied successfully.") Else Msgbox(0,"Error", "The backup did not complete successfully. Only " & $decimalplaceMBcopy & " Mb of " & $decimalplaceMBorig & " Mb copied successfully.") EndIf EndFuncEdit: ive updated the code, it now used a GUI folder select Otion, GUI make new folder, thx go out to slimshady for helping me get the variable copyfolder function 60+ views and no replys??, does sum1 wanna leave sum feedback plz <{POST_SNAPBACK}>hi burrup I have test it looks good,but i have Trouble, i have adde a new folder to copy from my destop to ohter place on my pc ,but he copy all files from it,but not the folder wat i have adde, to copy=? And he gif me this error from your code!The backup did not complete successfully. Only!Wy =?Your codeexpandcollapse popup$origdirect = FileSelectFolder("Please select the folder you wish to backup.", "") If @error = 1 Then Exit Else $copydirect = FileSelectFolder("Where would you like to backup this folder to.", "", 1) If @error = 1 Then Exit Else CopyFolder($origdirect, $copydirect) EndIf EndIf Func CopyFolder($Folder1, $Folder2) Local $ProcID $ProcID = Run(@ComSpec & ' /c xcopy /e /h /y "' & $Folder1 & '" "' & $Folder2 & '"', "", @SW_HIDE) ProgressOn("Progress Meter", "") $origfilesize = DirGetSize($Folder1) Do $copyfilesize = DirGetSize($Folder2) $MBcopy = dirGetSize($Folder2) / 1024 / 1024 $percent = $copyfilesize / $origfilesize * 100 $decimalplace = Round ($percent) $decimalplaceMBcopy = Round ($MBcopy) ProgressSet ($percent, $decimalplace & "% " & "(" & _ $decimalplaceMBcopy & ") Mb has been copied.") Sleep(500) Until NOT ProcessExists($ProcID) ProgressOff () $copyfilesize = DirGetSize($Folder2) $MBorig = dirGetSize($Folder1) / 1024 / 1024 $decimalplaceMBorig = Round ($MBorig) If $origfilesize = $copyfilesize then Msgbox(0,"Backup Complete", "All " & $decimalplaceMBcopy & " Mb of files and folders were copied successfully.") Else Msgbox(0,"Error", "The backup did not complete successfully. Only " & $decimalplaceMBcopy & " Mb of " & $decimalplaceMBorig & " Mb copied successfully.") EndIf EndFunc Edited January 6, 2005 by DirtyBanditos Link to comment Share on other sites More sharing options...
buzz44 Posted January 7, 2005 Author Share Posted January 7, 2005 hello, thanks for replyig, i think i know the problem, to check if all your files were copied it checks the original file size with the copied one, the problem u have just discovered is if u copy the original folder, into another folder were u already have files, the 2 folder will not equal the same size, therefor to not get this error you must make a new folder to copy the files to or you must make sure that the folder you copy it to is empty. try that and see how it goes qq Link to comment Share on other sites More sharing options...
buzz44 Posted January 7, 2005 Author Share Posted January 7, 2005 also just thought of a way to fix that, i got an idea to fix the problem for good here it is > When you select the folder it makes a list of all the files/ folder in it > At the end of the copy you could use the FileExist function to check each file/folder and see if it is there, that way would be much for reliable than checking and comparing the 2 flder sizes. any help on a way to get a list of all the files/folders in the original directory?? qq Link to comment Share on other sites More sharing options...
DirtyBanditos Posted January 7, 2005 Share Posted January 7, 2005 also just thought of a way to fix that, i got an idea to fix the problem for goodhere it is> When you select the folder it makes a list of all the files/ folder in it> At the end of the copy you could use the FileExist function to check each file/folder and see if it is there,that way would be much for reliable than checking and comparing the 2 flder sizes.any help on a way to get a list of all the files/folders in the original directory??<{POST_SNAPBACK}> Hi burrup thx for your help infos, it wörks good wis your tips))Good job thx for help me out Link to comment Share on other sites More sharing options...
buzz44 Posted January 8, 2005 Author Share Posted January 8, 2005 no problem, im currently working on the idea i explored in my last topic, should be finished soon qq Link to comment Share on other sites More sharing options...
tazdev Posted January 12, 2005 Share Posted January 12, 2005 Am I missing something? I ran it but I get an error. Is there an include file missing or do I have the wrong version of AutoIT. I installed it last week so I doubt it. ---------------------------------------------- Error is: AutoIt Error Line 19 (File "V:\AutoIT Scripts\Scripts\backup folders.au3") $origfilesoze = DirGetSize($Folder1) $origfilesoze = ^ ERROR Error: Unknown function name. ----------------------------------------------- I searched the Help file and cannot find a function called DirGetSize. Below is the code I am using. I am using MetaPad to write. expandcollapse popup$origdirect = FileSelectFolder("Please select the folder you wish to backup.", "") If @error = 1 Then Exit Else $copydirect = FileSelectFolder("Where would you like to backup this folder to.", "", 1) If @error = 1 Then Exit Else CopyFolder($origdirect, $copydirect) EndIf EndIf Func CopyFolder($Folder1, $Folder2) Local $ProcID $ProcID = Run(@ComSpec & ' /c xcopy /e /h /y "' & $Folder1 & '" "' & $Folder2 & '"', "", @SW_HIDE) ProgressOn("Progress Meter", "") $origfilesize = DirGetSize($Folder1) Do $copyfilesize = DirGetSize($Folder2) $MBcopy = dirGetSize($Folder2) / 1024 / 1024 $percent = $copyfilesize / $origfilesize * 100 $decimalplace = Round ($percent) $decimalplaceMBcopy = Round ($MBcopy) ProgressSet ($percent, $decimalplace & "% " & "(" & _ $decimalplaceMBcopy & ") Mb has been copied.") Sleep(500) Until NOT ProcessExists($ProcID) ProgressOff () $copyfilesize = DirGetSize($Folder2) $MBorig = dirGetSize($Folder1) / 1024 / 1024 $decimalplaceMBorig = Round ($MBorig) If $origfilesize = $copyfilesize then Msgbox(0,"Backup Complete", "All " & $decimalplaceMBcopy & " Mb of files and folders were copied successfully.") Else Msgbox(0,"Error", "The backup did not complete successfully. Only " & $decimalplaceMBcopy & " Mb of " & $decimalplaceMBorig & " Mb copied successfully.") EndIf EndFunc Link to comment Share on other sites More sharing options...
tazdev Posted January 12, 2005 Share Posted January 12, 2005 NM It occured to me to do a search of the forums for DirGetSize and Larry has it listed in the Beta Version. I don't have that version so I may get it then. LOL Link to comment Share on other sites More sharing options...
tazdev Posted January 12, 2005 Share Posted January 12, 2005 Installed the Beta Version and it works now. Niiiiiiiiiiiiiiiiice. I assume changing the vars a bit will result in it showing the progress bar as files are copied over instead of a comparison. After that I want to see if I can get it to only copy files with same name but newer dates. I searched the forums and didn't find anything but I may have searched for the wrong terms. 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