New kinda BackUp question...

Discussion in 'AutoCAD' started by Dr. After, Dec 6, 2004.

  1. Dr. After

    Dr. After Guest

    I have been working on getting all essential files for AutoCAD backed up and
    finally have the script working to get all files that I need with the
    exception of one. The temporary backup directory. By default it goes to
    Local User settings temp folder. And that is fine, but over a short amount
    of time it can grow to very large sizes. I actually only need to back up
    about the previous 10 days from the time of back up, though. So here goes
    my question:

    How can I either make a folder delete files after a certain amount of days
    have passed?
    or
    How can I only backup the files in a folder that have been modified or
    created within the last 10 days?
     
    Dr. After, Dec 6, 2004
    #1
  2. Dr. After

    RDI Guest

    Doc,

    Have a look at the dos command XCOPY. It contains an option to copy files
    that've been changed/created after a certain date. Use that to copy the
    files you're after.

    Once you've copied the ones you want to keep, you can delete the others.
     
    RDI, Dec 6, 2004
    #2
  3. Dr. After

    Dr. After Guest

    *RDI* typed some great info as displayed here:

    | Have a look at the dos command XCOPY. It contains an option to copy
    | files that've been changed/created after a certain date. Use that to
    | copy the files you're after.

    That is in fact the command I am using, but it will only set to one specific
    date. What I need it to do is copy everything that has been created or
    modified ten days before today (note: where today is a variable). Is that
    possible?
     
    Dr. After, Dec 6, 2004
    #3
  4. Dr. After

    RDI Guest

    So you only want to keep things that are OLDER than a certain date? I
    thought you wanted to get rid of things that were older.

    It sounds like it'll take a little more thought.
     
    RDI, Dec 6, 2004
    #4
  5. Dr. After

    RDI Guest

    Try setting the ARCHIVE attribute on everything the directory (use the
    attrib command to do this).
    Then XCopy with the date function and the /M option. After copying the
    files, it'll turn the archive attribute OFF. The remaining files (the ones
    NOT meeting your date spec) will still have the archive attribute set.

    Now use XCOPY again this time--tell it to copy ONLY files with the archive
    attrbute set.

    Watch the word wrap below.

    example for the following batch file (this one will include files in
    sub-folders): mybackup.bat "c:\Source Directory\" "c:\Destination
    Directory" 12-06-04 s

    example for the following batch file (this one will not include files in
    sub-folders): mybackup.bat "c:\Source Directory\" "c:\Destination
    Directory" 12-06-04
    @echo off
    rem the first arguement should be the source path.
    rem the second argument should be the destination path of your final files.
    rem the third arguemnt should be the date
    rem if you want to perform this operation on files in sub-folders as well,
    the
    rem fourth argument should be s (otherwise leave it blank.

    attrib %1\*.* +a %4

    md c:\temp-xc\

    xcopy %1 c:\temp-xc /m /d:%3

    copy c:\temp-xc %2 /m

    rd c:\temp-xc /S /Q
     
    RDI, Dec 6, 2004
    #5
  6. Dr. After

    RDI Guest

    I just realized a mistake in the "batch file". Change the line which reads
    "copy c:\temp-xc %2 /m" to say "XCopy %1 %2 %4"
     
    RDI, Dec 6, 2004
    #6
  7. Dr. After

    Dr. After Guest

    *RDI* typed them thar words:

    | So you only want to keep things that are OLDER than a certain date? I
    | thought you wanted to get rid of things that were older.

    No... You had it right the first time. I need all things between x-(x-10)
    where x=today. Everything else is not important.
     
    Dr. After, Dec 6, 2004
    #7
  8. Dr. After

    Don I Guest

    Oh that's easy then.

    From XCopy's help:
    /D:m-d-y Copies files changed on or after the specified date.
    If no date is given, copies only those files whose
    source time is newer than the destination time.

    Therefore the following will copy all files AFTER 12/1/04 (between 12/1 and
    today).

    xcopy "c:\test directory\*.*" "c:\Destination Directory\*.*" /d:12-1-04
     
    Don I, Dec 6, 2004
    #8
  9. Dr. After

    Dr. After Guest

    *Don I* typed them thar words:

    | xcopy "c:\test directory\*.*" "c:\Destination Directory\*.*"
    | /d:12-1-04

    Not so easy... because then I have to manualy go into the script and change
    the date, because that may work fine for today, but tomorrow I will need it
    to be 12-2-04, and then the day after that it will need to be 12-3-04. What
    I was hoping for was a switch that backed up everything from 10 days before
    the current date to the current date. So any set date would not work. It
    need to be a variable...

    Any ideas?
     
    Dr. After, Dec 7, 2004
    #9
  10. Does it need to be a script? If you can use Lisp, you can extract the
    elements of the date from the CDATE system variable with (substr) and put
    them together into the form the /d switch wants with (strcat). The part
    about ten days ago is the tricky one, when that would involve going back
    into the previous month. You'd probably have to compare the 7th and 8th
    characters of CDATE to see whether they're 10 or less, and if so, subtract
    them from 10 and take the remainder off of 28 (to cover all possible
    months), and reduce the 5th and 6th characters by one. But you would also
    have to compare those, and if they're 01, change them to 12 instead of 00.
    Anyway, as complicated as it may be, I think it could be done.
     
    Kent Cooper, AIA, Dec 7, 2004
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.