Author Topic: Keeping multiple file versions [Backup, auto save, time tag]  (Read 2588 times)

0 Members and 1 Guest are viewing this topic.

simor

  • Guest
Keeping multiple file versions [Backup, auto save, time tag]
« on: September 17, 2008, 10:14:38 AM »
Hi,

I'm looking for a Lisp (or other) procedure to create / keep multiple versions (backups) of DWG files.

I found this code:

Code: [Select]
(DEFUN c:nsave ( / dname dpref bdir dbac)

(setq dname (getvar "DWGNAME"))
(setq dpref (getvar "DWGPREFIX"))
(setq bdir (strcat "C:/ACADBACK/" dname))
(command "Qsave")
(setq dbac (vl-file-copy (getvar "savename") bdir))
(if (= dbac nil)
(progn
(vl-file-delete bdir)
(vl-file-copy (getvar "savename") bdir)
)
)
(setq sname (strcat "File Saved To "dpref dname))
(setq sname1 (strcat sname "\nFile Saved To "bdir))
(ALERT sname1 )

(princ)
);END QSAVE

which seems to do half of the job but I'd like the backup files to be tagged with current date & time.

I also found this: http://discussion.autodesk.com/thread.jspa?messageID=4083449 where James posted his saveNbackup-0.8.zip with VLX procedure. Unfortunately, according to the doc it only adds current date to the file name :(

I don't know lisp that much to be able to add time to the file name, can anyone help me with it, please?

regards
simon

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Keeping multiple file versions [Backup, auto save, time tag]
« Reply #1 on: September 17, 2008, 10:50:34 AM »
This should work for you. The Directory my already exist.
Code: [Select]
;;  CAB version modified 09.17.2008
(DEFUN c:nsave (/ dname dpref bdir dbac d time)
  ;;  date2String
  (setq d (rtos (getvar "CDATE") 2 6)
        d (strcat (substr d 7 2) "-" (substr d 5 2) "-" (substr d 3 2))
  )
  ;;  Time2String
  (setq time (rtos (getvar "CDATE") 2 6)
        time (strcat (substr time 10 2) "."(substr time 12 2) "." (substr time 14 2))
  )
  (setq dname (strcat (vl-filename-base (getvar "DWGNAME")) "_" d "_" time ".DWG"))
  (setq dpref (getvar "DWGPREFIX"))
  (setq bdir (strcat "C:/ACADBACK/" dname))
  (command "Qsave")
  (setq dbac (vl-file-copy (getvar "savename") bdir))
  (if (null dbac)
    (progn
      (vl-file-delete bdir)
      (vl-file-copy (getvar "savename") bdir)
    )
  )
  (ALERT (strcat "File Saved To " dpref dname "\nFile Saved To " bdir))
  (princ)
)         ;END nSAVE

<edit: tweaked the code a bit>
« Last Edit: September 17, 2008, 10:57:23 AM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

simor

  • Guest
Re: Keeping multiple file versions [Backup, auto save, time tag]
« Reply #2 on: September 17, 2008, 11:07:42 AM »
Yes, that's perfect!

Thank you very much!

:lol:

GDF

  • Water Moccasin
  • Posts: 2081
Re: Keeping multiple file versions [Backup, auto save, time tag]
« Reply #3 on: September 17, 2008, 12:05:08 PM »
You may want to use "Backup" by James Buzbee and Kerry Brown (I think)

;|
Well copy the below code into your acaddoc.lsp and then get used to
typing "BAK" before you start any major (or minor for that matter)
changes to your drawing.  It will create a /BackUp directory, if not
already present, and a file with the date and time appended to the
drawing name: C:/MyProject/X_Site.dwg would be saved as
C:/MyProject/BackUp/X_Site-2006.03.30.18.32.39.dwg.
|;

It's here somewhere in the swamp...(I think)
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Keeping multiple file versions [Backup, auto save, time tag]
« Reply #4 on: September 17, 2008, 12:14:17 PM »
You may want to use "Backup" by James Buzbee and Kerry Brown (I think)

;|
Well copy the below code into your acaddoc.lsp and then get used to
typing "BAK" before you start any major (or minor for that matter)
changes to your drawing.  It will create a /BackUp directory, if not
already present, and a file with the date and time appended to the
drawing name: C:/MyProject/X_Site.dwg would be saved as
C:/MyProject/BackUp/X_Site-2006.03.30.18.32.39.dwg.
|;

It's here somewhere in the swamp...(I think)


Here are the links...

;;;James Buzbee
;;;http://www.theswamp.org/index.php?topic=9453.0

;;;Kerry Brown
;;;http://www.theswamp.org/index.php?topic=9696.0

Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Keeping multiple file versions [Backup, auto save, time tag]
« Reply #6 on: September 17, 2008, 12:25:15 PM »
Yes, that's perfect!

Thank you very much!

:lol:
You're welcome and welcome to TheSwamp. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

simor

  • Guest
Re: Keeping multiple file versions [Backup, auto save, time tag]
« Reply #7 on: September 18, 2008, 09:55:52 AM »
I sure feel welcome with so many solutions that I somehow missed while searching :oops:

Thanks again! Here's what I came up with but in VBA: http://www.theswamp.org/index.php?topic=24992.0

Maybe I'll expand it with keeping last N versions at some point if free disk space becomes a problem in here :wink: