Jump to content

Backing up files & directories


Recommended Posts

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!

:lmao:

max

Link to comment
Share on other sites

don't use the word hack.

else people will think ur me :lmao:

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

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 by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...