maxcronjob 0 Posted February 15, 2005 Hi all, anyone have a solution to how I can run a script that will copy a directory and it's subdirectories and files and dump them into another directory (copying over all the subdirectories & files too) BUT be able to check each file before copying it in. IF a file exists with the same name, rename the old file with _old_<date> and then copy in the new one. Seems like FileCopy and DirCopy are limited as to what we can do with them. anyone have any good hacks? thanks! max Share this post Link to post Share on other sites
zeroZshadow 0 Posted February 15, 2005 don't use the word hack. else people will think ur me mabye you can use a for next statement to check then copy each file seperatly *If u thought life couldn't get worse, u meet me *<guy> What would you give my little sister to unzip ?<friend> 10 bucks<guy> No, i mean like Winzip... Share this post Link to post Share on other sites
maxcronjob 0 Posted February 15, 2005 don't use the word hack.else people will think ur me mabye you can use a for next statement to check then copy each file seperatly<{POST_SNAPBACK}>Right on. Can you shed some light on how I'd set that up. DirCopy(src, dest, 0) for...?max Share this post Link to post Share on other sites
Blue_Drache 260 Posted February 15, 2005 (edited) Right on. Can you shed some light on how I'd set that up. DirCopy(src, dest, 0) for...?max<{POST_SNAPBACK}>I'd use something like this:a mix of real and psuedocode follows#include <date.au3> $fileA = C:\old.txt $fileB = C:\new.txt $DateOldArray = FileGetTime($fileA,0,0) ; make this array into a format that the function _DateDiff can handle. $DateOld = $DateOldArray[0] & "/" $DateOldArray[1] & "/" $DateOldArray[2] & " " & $DateOldArray[3] & ":" & $DateOldArray[4] & ":" & $DateOldArray[5] $DateNew = FileGetTime($fileB,0,0) ; make this array into a format that the function _DateDiff can handle, I'm lazy, copy the above one. $timediff = _DateDiff("s",$DateNew,$DateOld) ; debug section MsgBox(0,"$timediff","Difference between file dates: " & $timediff) exit ; end debug If $timediff is postitive or greater than zero then ; do your backup rename function ElseIf $timediff is negative, zero, or less than zero, then ; skip it, the backup is current. EndIf Edited February 15, 2005 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Share this post Link to post Share on other sites