maxcronjob Posted February 15, 2005 Share 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 Link to comment Share on other sites More sharing options...
zeroZshadow Posted February 15, 2005 Share 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... Link to comment Share on other sites More sharing options...
maxcronjob Posted February 15, 2005 Author Share 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 Link to comment Share on other sites More sharing options...
Blue_Drache Posted February 15, 2005 Share 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 Link to comment Share on other sites More sharing options...
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