Backup Solution using FileCopy

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kadhri
Posts: 49
Joined: 12 Nov 2015, 06:52

Backup Solution using FileCopy

21 Mar 2017, 04:42

Hi All,

I want to copy a file to a new location (say "dest"), when ever it get modified in source (say "src")
I want to keep all the copies with out overwriting (ok with Flag 0)

I am using FileGetDate, to compare last modified attributes

I want make my source file is the file which was last modified

Code: Select all

source=d:\*.ods
dest=d:\backup

FileGetTime, MDS, %source%, M
FileCopy, %source%, %dest%\
FileGetTime, MDD, %dest%\*.ods, M

loop
{
if(MDS!=MDD)
 {
 source1=%dest%\*.ods
 FileCopy, %source1%, %dest%\backup_%A_Index%.ods
 }
}
here i always want to do the copied file is my new source

Thanks in Advance,
k@D
Albireo
Posts: 1756
Joined: 16 Oct 2013, 13:53

Re: Backup Solution using FileCopy

21 Mar 2017, 07:43

I'm not sure what you want to do.
What I know is that FileGetTime... only can look on one file (not all file at same time)
I would look at the following example (from the helpfile)

Code: Select all

CopyFilesAndFolders(SourcePattern, DestinationFolder, DoOverwrite = false)
; 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
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 242 guests