multi file copy functions in single AHK
Posted: 26 Oct 2020, 16:44
I'm new to AHK and hoping to get some help...it would seem pretty simple what I am trying to do. I basically want to copy a couple of specific files to a backup folder... then copy all files/folders to the destination folder where I need it, overwrite is enabled. The first 2 lines of code I attempted this but it doesn't work.. its being ignored, do I need to add a pause or what am I missing.
Code: Select all
FileCopy, D:\Launchbox\Data\Playlists\Favorites.xml, D:\[ LB Data Backup ]\Data\Playlists\
FileCopy, D:\Launchbox\Data\Playlists\Family Favorites.xml, D:\[ LB Data Backup ]\Data\Playlists\
ErrorCount := CopyFilesAndFolders("D:\[ LB Data Backup ]\Data\*.*", "D:\Launchbox\Data")
if (ErrorCount != 0)
MsgBox %ErrorCount% files/folders could not be copied.
CopyFilesAndFolders(SourcePattern, DestinationFolder, DoOverwrite = true)
; Copies all files and folders matching SourcePattern into the folder named DestinationFolder and
; returns the number of files/folders that could not be copied.
{
; First copy all the files (but not the folders):
FileCopy, %SourcePattern%, %DestinationFolder%, %DoOverwrite%
ErrorCount := ErrorLevel
; Now copy all the folders:
Loop, %SourcePattern%, 2 ; 2 means "retrieve folders only".
{
FileCopyDir, %A_LoopFileFullPath%, %DestinationFolder%\%A_LoopFileName%, %DoOverwrite%
ErrorCount += ErrorLevel
if ErrorLevel ; Report each problem folder by name.
MsgBox Could not copy %A_LoopFileFullPath% into %DestinationFolder%.
}
return ErrorCount
}