_CopyRobo() Folder And File Copy With Robocopy


SUBMITTED BY: Guest

DATE: May 30, 2013, 7:49 a.m.

FORMAT: Text only

SIZE: 2.7 kB

HITS: 2269

  1. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7
  2. ; Needs Robocopy Version XP_026 or XP_027 for $sCopyParams Compatibility (C:\windows\system32\)
  3. ;XP_027 installed in Vista or greater ( Not for XP )
  4. Local Const $sSource = @UserProfileDir & '\Desktop'
  5. Local Const $sDestination = 'D:\Backup\Desktop'
  6. Local Const $sSearchParams = '*.*' ; _Change_String('*.jpg|*.png') for multiple selections
  7. Local Const $sCopyParams = '/COPY:D /S /ZB /XJD /XJF /R:0 /W:0 /XA:SHT /NJS'
  8. ; /COPY:D = Copy Data /S = Copy Subfolders /ZB = Use Restartable Mode /XJD = Exclude junction Points For Directorys /XJF = Exclude junction Points For Files
  9. ; /R:0 = Retry Time - 0 /W:0 = Wait Time - 0 /XA:SHT = No System / Hidden or Temp Files Backed Up /NJS = No Job Summary in the CMD window
  10. Local Const $sExcludeFiles = '/XF ' & _Change_String('add.ini|your.ini|files.ini|to.ini|exclude.ini|here.ini') ; e.g. '*.iss|*.lnk|*.properties|*.session|aaw7boot.log|Amanda.wma'
  11. Local Const $sExcludeFolders = '/XD ' & '"' & $sDestination & '"' & ' ' & _Change_String('Add|your|folders|to|exclude|here') ; e.g. 'ATI|AMD|Intel|Program Files|Program Files (x86)|Windows'
  12. _CopyRobo($sSource, $sDestination, $sSearchParams, $sCopyParams, $sExcludeFiles, $sExcludeFolders)
  13. Func _CopyRobo($sSourceFolder, $sDestFolder, $sSearchParams, $sCopyParams, $sExcludeFiles, $sExcludeFolders)
  14. DirRemove($sDestFolder, 1)
  15. Local Const $iSourceSize = DirGetSize($sSourceFolder)
  16. Local Const $iRoboPID = Run('robocopy.exe' & ' ' & '"' & $sSourceFolder & '"' & ' ' & '"' & $sDestFolder & '"' & ' ' & $sSearchParams & ' ' & $sCopyParams & ' ' & $sExcludeFiles & ' ' & $sExcludeFolders, '', @SW_SHOW); @SW_HIDE Once its working
  17. Local $iPercent = 0
  18. ProgressOn('Copy Progress', 'Please Wait...')
  19. Do
  20. $iPercent = Int((DirGetSize($sDestFolder) / $iSourceSize) * 100)
  21. ProgressSet($iPercent, $iPercent & ' percent complete')
  22. Sleep(20)
  23. Until Not ProcessExists($iRoboPID)
  24. ProgressOff()
  25. EndFunc ;==>_CopyRobo
  26. Func _Change_String($sString)
  27. Return '"' & StringReplace($sString, "|", '" "') & '"'
  28. EndFunc ;==>_Change_String
  29. ;~ ConsoleWrite("Search Files Params = " & $sSearchParams & @CRLF) ; For double cheking
  30. ;~ ConsoleWrite("Exclude FileList Params = " & $sExcludeFiles & @CRLF) ; For double cheking
  31. ;~ ConsoleWrite("Exclude FolderList Params = " & $sExcludeFolders & @CRLF) ; For double cheking

comments powered by Disqus