geomor Posted January 29, 2015 Posted January 29, 2015 Hi Guys, New to the scripting scene so bare with me here, I am having some torubles with my script. I found a script that copies a folder from source to destination that shows a progress bar on the forums here. The sole purpose of the script is to create an incremental backup of users profile to a server. Now I have set the source folder to the profile directory on a win7 machine, @UserProfileDir should be sufficeient for this? Once i run the script it doesnt copy a single file and displays no errors. I understand not all files will be copied due to locked/in use files but that is okay. Any help would be greatly appreciated I have attached the script below expandcollapse popup$origdirect = @UserProfileDir $copydirect = "C:\temp\test" ;DriveMapAdd ("X:","\\test\temp") If FileExists ($copydirect) then If msgbox(1, "Confirmation", "The directory already exists. Are you sure you want to replace it?") = 2 Then Exit ;Else CopyFolder($origdirect, $copydirect) Else If msgbox(1, "Confirmation", "The specified directory doesnt exist. Would you like to create it?") = 1 then DirCreate ($copydirect) CopyFolder($origdirect, $copydirect) Else Exit EndIf EndIf Func CopyFolder($Folder1, $Folder2) Local $ProcID $ProcID = Run(@ComSpec & ' /c xcopy /e /h /r /y /i /d "' & $Folder1 & '" "' & $Folder2 & '"', "", @SW_HIDE) ProgressOn("Progress Meter", "") $origfilesize = DirGetSize($Folder1) Do $copyfilesize = DirGetSize($Folder2) $MB = dirGetSize($Folder2) / 1024 / 1024 $percent = $copyfilesize / $origfilesize * 100 $decimalplace = Round ($percent) $decimalplaceMB = Round ($MB) ProgressSet ($percent, $decimalplace & " % " & "(" & _ $decimalplaceMB & ") Mb has been copied.") Sleep(500) Until NOT ProcessExists($ProcID) ProgressOff () $copyfilesize = DirGetSize($Folder2) If $origfilesize = $copyfilesize then Msgbox(0,"Complete", "All files and folders have been copied successfully.") Else Msgbox(0,"Error", "1 or more of the files/folders did not copy correctly.") EndIf EndFunc DriveMapDel("X:")
javiwhite Posted January 29, 2015 Posted January 29, 2015 (edited) Hi Geomor and welcome to the forums, This may be due to the way xcopy works in batch script. EDIT: Further info. The "*.*" symbols in batch script are wildcards that basically mean any filename (the first asterisk) . any file extension (the second). Try changing your run command to the following, and see how that works for you: $ProcID = Run(@ComSpec & ' /c xcopy /e /h /r /y /i /d "' & $Folder1 & '\*.*" "' & $Folder2 & '"', "", @SW_HIDE) - Javi Edited January 29, 2015 by javiwhite give a man an application, and he'll be frustrated for the day, Teach him how to program applications and he'll be frustrated for a lifetime.
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