PDA

View Full Version : Copying files incrementally



Mango
08-04-2009, 04:12 PM
Hi

I need to backup a large quantity of files to a destination where many already exist, so I only want to copy new or modified files. AMS7 only allows not to overwrite a file if the name is the same. Anybody know how can I tell it to overwrite if the name is the same, but date is newer?

mystica
08-04-2009, 08:32 PM
File.GetAttributes will return the files' creation-date down to minutes and seconds, if you use CreationDateISO in the table.

eg.

fSelect = Dialog.FileBrowse(true, "File to Copy", _DesktopFolder, "All Files (*.*)|*.*|", "", "dat", false, false);
attrib = File.GetAttributes(fSelect[1]);
strCreationDateISO = attrib.CreationDateISO;
Dialog.Message("Notice", strCreationDateISO, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);

An if/then statement to compare the 2 files in question, will allow you to copy the newer file.

But the only problem that I can't figure out is how to convert the date formats into comparable-strings. Perhaps someone else can jump in here.

longedge
08-05-2009, 01:32 AM
But the only problem that I can't figure out is how to convert the date formats into comparable-strings. Perhaps someone else can jump in here.

You can compare directly once you've got the .CreationDateISO for both files.

If the files are from the same originals and the new ones have simply been updated with new information it would probably be better to compare the .WriteDateISO

Mango
08-05-2009, 09:22 AM
Thanks a lot guys
Thats great advice - I'll give it a go and I might be able to use the DateDiff plugin to compare the dates. I'll let you know how I get on.
:yes