Jump to content

Progress Bar


buzz44
 Share

Recommended Posts

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

$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 :idiot:

60+ views and no replys??, does sum1 wanna leave sum feedback plz :D

Edited by burrup

qq

Link to comment
Share on other sites

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

$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 :idiot:

60+ views and no replys??, does sum1 wanna leave sum feedback plz :D

<{POST_SNAPBACK}>

hi burrup :lol: 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 code

$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 by DirtyBanditos
Link to comment
Share on other sites

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 :idiot:

qq

Link to comment
Share on other sites

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

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

<{POST_SNAPBACK}>

:D Hi burrup thx for your help infos, it wörks good wis your tips))

Good job thx for help me out :idiot:

Link to comment
Share on other sites

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.

$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

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

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