<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Save copy of drawing to another folder without xrefs in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/6006278#M137400</link>
    <description>&lt;P&gt;Hi again!&amp;nbsp;&lt;BR /&gt;I was going through some backup files yesterday and noticed that the date format is not exactly as I wanted.&amp;nbsp;&lt;BR /&gt;For example todays date, 2016-01-26 gets written as 16126. This is a bit confusing since for example 2016-10-11 gets written as 161011 and 2016-01-01 as 1611.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked through the script and found that the reason is probably that the code says YYMD. What I really want is YYMMDD so that 2016-01-01 is written as 160101. I tried to change the code to YYMMDD but that resulted in todays date 2016-01-26 being written as 161426. Which is not what I want. I don't even understand where it got the "4" from.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to fix this so that numbers &amp;lt;10 gets a 0 in front of them? This would be much appreciated as it would create consitency in the file order.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jan 2016 09:38:51 GMT</pubDate>
    <dc:creator>jens.tornblad</dc:creator>
    <dc:date>2016-01-26T09:38:51Z</dc:date>
    <item>
      <title>Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5874990#M137391</link>
      <description>&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have a certain process at our workplace where we have a working folder and a folder where we save the most recent version of the file without xrefs. We also have an old folder where the previous version of the drawing in the recent folder is moved to.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to automate this proccess with a script?&amp;nbsp;&lt;/P&gt;&lt;P&gt;What we need is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;All xrefs detached&lt;/LI&gt;&lt;LI&gt;UCS world&lt;/LI&gt;&lt;LI&gt;Save a copy of the drawing with the same name to the "recent" folder and also move the (if) existing file to "old" with the same name but _YYMMDD at the end.&lt;/LI&gt;&lt;LI&gt;Keep the "working" drawing open in Autocad&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;BR /&gt;Ultimately this would all be achieved with a keyboard shortcut.&lt;/P&gt;&lt;P&gt;Is this possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2015 11:17:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5874990#M137391</guid>
      <dc:creator>jens.tornblad</dc:creator>
      <dc:date>2015-10-23T11:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5875047#M137392</link>
      <description>This might help you with some... &lt;BR /&gt;&lt;A href="http://www.cadstudio.cz/en/apps/suresave/" target="_blank"&gt;http://www.cadstudio.cz/en/apps/suresave/&lt;/A&gt;</description>
      <pubDate>Fri, 23 Oct 2015 12:13:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5875047#M137392</guid>
      <dc:creator>ВeekeeCZ</dc:creator>
      <dc:date>2015-10-23T12:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5875470#M137393</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3376665"&gt;@jens.tornblad&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hi!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We have a certain process at our workplace where we have a working folder and a folder where we save the most recent version of the file without xrefs. We also have an old folder where the previous version of the drawing in the recent folder is moved to.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is it possible to automate this proccess with a script?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What we need is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;All xrefs detached&lt;/LI&gt;
&lt;LI&gt;UCS world&lt;/LI&gt;
&lt;LI&gt;Save a copy of the drawing with the same name to the "recent" folder and also move the (if) existing file to "old" with the same name but _YYMMDD at the end.&lt;/LI&gt;
&lt;LI&gt;Keep the "working" drawing open in Autocad&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;BR /&gt;Ultimately this would all be achieved with a keyboard shortcut.&lt;/P&gt;
&lt;P&gt;Is this possible?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;Hello jens.tornblad and welcome to the Autodesk Community!&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;yes, it is possible.&lt;/P&gt;
&lt;P&gt;Quick and dirty...&lt;BR /&gt;Change the 'old' and 'recent' paths, to the correct ones...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:demo (/ *error* adoc dwg)
    (setq adoc (vla-get-activedocument (vlax-get-acad-object)))

    (defun *error* (msg)
        (vla-endundomark adoc)
        (cond
            ((not msg))
            ((member msg '("Function cancelled" "quit / exit abort")))
            ((princ (strcat "\n** Error: " msg " ** ")))
        )
        (if command-s
            (command-s "_.undo" "")
            (command "_.undo" "")
        )
        (princ)
    )

    (vla-startundomark adoc)
    (command "_.-xref" "_D" "*")
    (command "_.qsave")
    (command "_.ucs" "_W")
    (setq dwg (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 4)))
    (if (findfile (strcat "c:/Test/recent/" (getvar 'dwgname)))
        (if (findfile (strcat "c:/Test/old/" dwg "_" (menucmd "M=$(edtime,$(getvar,date),YYMD)") ".dwg"))
            (progn
                (vl-file-delete (strcat "c:/Test/old/" dwg "_" (menucmd "M=$(edtime,$(getvar,date),YYMD)") ".dwg"))
                (vl-file-copy
                    (strcat "c:/Test/recent/" (getvar 'dwgname))
                    (strcat "c:/Test/old/" dwg "_" (menucmd "M=$(edtime,$(getvar,date),YYMD)") ".dwg")
                )
                (vl-file-delete (strcat "c:/Test/recent/" (getvar 'dwgname)))
                (vl-file-copy
                    (strcat (getvar 'dwgprefix) (getvar 'dwgname))
                    (strcat "c:/Test/recent/" (getvar 'dwgname))
                )
            )
            (progn
                (vl-file-copy
                    (strcat "c:/Test/recent/" (getvar 'dwgname))
                    (strcat "c:/Test/old/" dwg "_" (menucmd "M=$(edtime,$(getvar,date),YYMD)") ".dwg")
                )
                (vl-file-delete (strcat "c:/Test/recent/" (getvar 'dwgname)))
                (vl-file-copy
                    (strcat (getvar 'dwgprefix) (getvar 'dwgname))
                    (strcat "c:/Test/recent/" (getvar 'dwgname))
                )
            )
        )
        (vl-file-copy
            (strcat (getvar 'dwgprefix) (getvar 'dwgname))
            (strcat "c:/Test/recent/" (getvar 'dwgname))
        )
    )
    (*error* nil)
    (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps, &lt;BR /&gt;Henrique&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Oct 2015 15:03:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5875470#M137393</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2015-10-23T15:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5877660#M137394</link>
      <description>&lt;P&gt;Wow! This is great! Real timesaver! A couple of questions regarding a couple of changes I thought of when I tried it out.&amp;nbsp;&lt;BR /&gt;Is it possible to also purge the file? I tried adding&lt;/P&gt;&lt;PRE&gt;(command "_.-purge" "_A" "*" "_N")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;after&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    (vla-startundomark adoc)
    (command "_.-xref" "_D" "*")
    (command "_.qsave")
    (command "_.ucs" "_W")&lt;/PRE&gt;&lt;P&gt;without any luck. It purges the file but then the script appears to stop. I only want the "recent" file to get purged.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also another change, if possible. I don't want the script to overwrite the old file if there's already one with the same date. In other words if an old file is already created for the day I don't want to overwrite that if the script is run again on that day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for the help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 09:26:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5877660#M137394</guid>
      <dc:creator>jens.tornblad</dc:creator>
      <dc:date>2015-10-26T09:26:33Z</dc:date>
    </item>
    <item>
      <title>Re: Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5877682#M137395</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3376665"&gt;@jens.tornblad&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Wow! This is great! Real timesaver! A couple of questions regarding a couple of changes I thought of when I tried it out.&amp;nbsp;&lt;BR /&gt;Is it possible to also purge the file? I tried adding&lt;/P&gt;
&lt;PRE&gt;(command "_.-purge" "_A" "*" "_N")&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;after&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    (vla-startundomark adoc)
    (command "_.-xref" "_D" "*")
    (command "_.qsave")
    (command "_.ucs" "_W")&lt;/PRE&gt;
&lt;P&gt;without any luck. It purges the file but then the script appears to stop. I only want the "recent" file to get purged.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also another change, if possible. I don't want the script to overwrite the old file if there's already one with the same date. In other words if an old file is already created for the day I don't want to overwrite that if the script is run again on that day.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for the help.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You're welcome, jens.tornblad!&lt;BR /&gt;The&lt;/P&gt;
&lt;PRE&gt;(command "_.-purge" "_A" "*" "_N")&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN class="hps"&gt;should&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;not&lt;/SPAN&gt; stop the code,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:demo (/ *error* adoc dwg dwg_old)
    (setq adoc (vla-get-activedocument (vlax-get-acad-object)))

    (defun *error* (msg)
        (vla-endundomark adoc)
        (cond
            ((not msg))
            ((member msg '("Function cancelled" "quit / exit abort")))
            ((princ (strcat "\n** Error: " msg " ** ")))
        )
        (if command-s
            (command-s "_.undo" "")
            (command "_.undo" "")
        )
        (princ)
    )

    (setq dwg (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 4)))
    (setq dwg_old (strcat "c:/Test/old/" dwg "_" (menucmd "M=$(edtime,$(getvar,date),YYMD)") ".dwg"))
    (cond ((not (findfile dwg_old))
           (vla-startundomark adoc)
           (command "_.-xref" "_D" "*")
           (command "_.qsave")
           (command "_.ucs" "_W")
           (command "_.-purge" "_A" "*" "_N")

           (if (findfile (strcat "c:/Test/recent/" (getvar 'dwgname)))
               (progn
                   (vl-file-copy
                       (strcat "c:/Test/recent/" (getvar 'dwgname))
                       (strcat "c:/Test/old/" dwg "_" (menucmd "M=$(edtime,$(getvar,date),YYMD)") ".dwg")
                   )
                   (vl-file-delete (strcat "c:/Test/recent/" (getvar 'dwgname)))
                   (vl-file-copy
                       (strcat (getvar 'dwgprefix) (getvar 'dwgname))
                       (strcat "c:/Test/recent/" (getvar 'dwgname))
                   )
               )

               (vl-file-copy
                   (strcat (getvar 'dwgprefix) (getvar 'dwgname))
                   (strcat "c:/Test/recent/" (getvar 'dwgname))
               )
           )
           (*error* nil)
          )
          (T
           (princ "\nA backup has already been created today... ")
          )
    )
    (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Untested, I don't have AutoCAD in this laptop...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps, &lt;BR /&gt;Henrique&lt;BR /&gt;&lt;BR /&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 09:56:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5877682#M137395</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2015-10-26T09:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5877700#M137396</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/75977"&gt;@hmsilva&lt;/a&gt; wrote:&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3376665"&gt;@jens.tornblad&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Wow! This is great! Real timesaver! A couple of questions regarding a couple of changes I thought of when I tried it out.&amp;nbsp;&lt;BR /&gt;Is it possible to also purge the file? I tried adding&lt;/P&gt;&lt;PRE&gt;(command "_.-purge" "_A" "*" "_N")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;after&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    (vla-startundomark adoc)
    (command "_.-xref" "_D" "*")
    (command "_.qsave")
    (command "_.ucs" "_W")&lt;/PRE&gt;&lt;P&gt;without any luck. It purges the file but then the script appears to stop. I only want the "recent" file to get purged.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also another change, if possible. I don't want the script to overwrite the old file if there's already one with the same date. In other words if an old file is already created for the day I don't want to overwrite that if the script is run again on that day.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for the help.&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;You're welcome, jens.tornblad!&lt;BR /&gt;The&lt;/P&gt;&lt;PRE&gt;(command "_.-purge" "_A" "*" "_N")&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="hps"&gt;should&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;not&lt;/SPAN&gt; stop the code,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun c:demo (/ *error* adoc dwg dwg_old)
    (setq adoc (vla-get-activedocument (vlax-get-acad-object)))

    (defun *error* (msg)
        (vla-endundomark adoc)
        (cond
            ((not msg))
            ((member msg '("Function cancelled" "quit / exit abort")))
            ((princ (strcat "\n** Error: " msg " ** ")))
        )
        (if command-s
            (command-s "_.undo" "")
            (command "_.undo" "")
        )
        (princ)
    )

    (setq dwg (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 4)))
    (setq dwg_old (strcat "c:/Test/old/" dwg "_" (menucmd "M=$(edtime,$(getvar,date),YYMD)") ".dwg"))
    (cond ((not (findfile dwg_old))
           (vla-startundomark adoc)
           (command "_.-xref" "_D" "*")
           (command "_.qsave")
           (command "_.ucs" "_W")
           (command "_.-purge" "_A" "*" "_N")

           (if (findfile (strcat "c:/Test/recent/" (getvar 'dwgname)))
               (progn
                   (vl-file-copy
                       (strcat "c:/Test/recent/" (getvar 'dwgname))
                       (strcat "c:/Test/old/" dwg "_" (menucmd "M=$(edtime,$(getvar,date),YYMD)") ".dwg")
                   )
                   (vl-file-delete (strcat "c:/Test/recent/" (getvar 'dwgname)))
                   (vl-file-copy
                       (strcat (getvar 'dwgprefix) (getvar 'dwgname))
                       (strcat "c:/Test/recent/" (getvar 'dwgname))
                   )
               )

               (vl-file-copy
                   (strcat (getvar 'dwgprefix) (getvar 'dwgname))
                   (strcat "c:/Test/recent/" (getvar 'dwgname))
               )
           )
           (*error* nil)
          )
          (T
           (princ "\nA backup has already been created today... ")
          )
    )
    (princ)
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Untested, I don't have AutoCAD in this laptop...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;BR /&gt;Henrique&lt;BR /&gt;&lt;BR /&gt;Henrique&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks again! Kudos for superfast reply!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Purge doesn't seem to work, I can see that it runs purge but when i open the "recent" file all excess layers and such still seem to be there.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also noticed that the working file is saved without xrefs, is it possible to change the order so detaching is done after qsave?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Lastly, with the new version the script doesn't run at all if there is already an old file. Maybe I explained unclear&amp;nbsp;before, but I would like the script to still run, just skip the step where the recent file is moved to old. In other words, I want everything to proceed as before just not overwrite the "old" file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again, amazing work!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 10:21:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5877700#M137396</guid>
      <dc:creator>jens.tornblad</dc:creator>
      <dc:date>2015-10-26T10:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5877720#M137397</link>
      <description>&lt;P&gt;&lt;SPAN class="hps alt-edited"&gt;Once again, untested...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun c:demo (/ *error* adoc dwg)
    (setq adoc (vla-get-activedocument (vlax-get-acad-object)))

    (defun *error* (msg)
        (vla-endundomark adoc)
        (cond
            ((not msg))
            ((member msg '("Function cancelled" "quit / exit abort")))
            ((princ (strcat "\n** Error: " msg " ** ")))
        )
        (if command-s
            (command-s "_.undo" "")
            (command "_.undo" "")
        )
        (if command-s
            (command-s "_.qsave")
            (command "_.qsave")
        )
        (princ)
    )

    (vla-startundomark adoc)
    (command "_.-xref" "_D" "*")
    (command "_.qsave")
    (command "_.ucs" "_W")
    (repeat 3 (command "_.-purge" "_A" "*" "_N"))
    (setq dwg (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 4)))
    (if (findfile (strcat "c:/Test/recent/" (getvar 'dwgname)))
        (if (findfile (strcat "c:/Test/old/" dwg "_" (menucmd "M=$(edtime,$(getvar,date),YYMD)") ".dwg"))
            (progn
                ;|(vl-file-delete (strcat "c:/Test/old/" dwg "_" (menucmd "M=$(edtime,$(getvar,date),YYMD)") ".dwg"))
                (vl-file-copy
                    (strcat "c:/Test/recent/" (getvar 'dwgname))
                    (strcat "c:/Test/old/" dwg "_" (menucmd "M=$(edtime,$(getvar,date),YYMD)") ".dwg")
                )|;
                (vl-file-delete (strcat "c:/Test/recent/" (getvar 'dwgname)))
                (vl-file-copy
                    (strcat (getvar 'dwgprefix) (getvar 'dwgname))
                    (strcat "c:/Test/recent/" (getvar 'dwgname))
                )
            )
            (progn
                (vl-file-copy
                    (strcat "c:/Test/recent/" (getvar 'dwgname))
                    (strcat "c:/Test/old/" dwg "_" (menucmd "M=$(edtime,$(getvar,date),YYMD)") ".dwg")
                )
                (vl-file-delete (strcat "c:/Test/recent/" (getvar 'dwgname)))
                (vl-file-copy
                    (strcat (getvar 'dwgprefix) (getvar 'dwgname))
                    (strcat "c:/Test/recent/" (getvar 'dwgname))
                )
            )
        )
        (vl-file-copy
            (strcat (getvar 'dwgprefix) (getvar 'dwgname))
            (strcat "c:/Test/recent/" (getvar 'dwgname))
        )
    )
    (*error* nil)
    (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="hps alt-edited"&gt;Hope this helps, &lt;BR /&gt;Henrique&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Oct 2015 10:44:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5877720#M137397</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2015-10-26T10:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5884062#M137398</link>
      <description>&lt;P&gt;Thank you very much for this! Like I said, really a timesaver and I just tested it on our real files and it works great. The only thing that I still can't get to work is purge. When I open the created file there are still a lot of stuff that gets deleted when I run purge manually. Should I just give up on purge and delete that line from the script?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Everything else works great. You just saved med tons of time since I had to do this manually before.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 15:21:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5884062#M137398</guid>
      <dc:creator>jens.tornblad</dc:creator>
      <dc:date>2015-10-29T15:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5884073#M137399</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3376665"&gt;@jens.tornblad&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thank you very much for this! Like I said, really a timesaver and I just tested it on our real files and it works great. The only thing that I still can't get to work is purge. When I open the created file there are still a lot of stuff that gets deleted when I run purge manually. Should I just give up on purge and delete that line from the script?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Everything else works great. You just saved med tons of time since I had to do this manually before.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You're welcome, jens.tornblad&lt;BR /&gt;Try to change the 'qsave' position in the code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(vla-startundomark adoc)
(command "_.-xref" "_D" "*")
 ;(command "_.qsave") from here
(command "_.ucs" "_W")
(repeat 3 (command "_.-purge" "_A" "*" "_N"))
(command "_.qsave") ;&amp;lt;= to here&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps, &lt;BR /&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Thu, 29 Oct 2015 15:26:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/5884073#M137399</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2015-10-29T15:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/6006278#M137400</link>
      <description>&lt;P&gt;Hi again!&amp;nbsp;&lt;BR /&gt;I was going through some backup files yesterday and noticed that the date format is not exactly as I wanted.&amp;nbsp;&lt;BR /&gt;For example todays date, 2016-01-26 gets written as 16126. This is a bit confusing since for example 2016-10-11 gets written as 161011 and 2016-01-01 as 1611.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked through the script and found that the reason is probably that the code says YYMD. What I really want is YYMMDD so that 2016-01-01 is written as 160101. I tried to change the code to YYMMDD but that resulted in todays date 2016-01-26 being written as 161426. Which is not what I want. I don't even understand where it got the "4" from.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is it possible to fix this so that numbers &amp;lt;10 gets a 0 in front of them? This would be much appreciated as it would create consitency in the file order.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 09:38:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/6006278#M137400</guid>
      <dc:creator>jens.tornblad</dc:creator>
      <dc:date>2016-01-26T09:38:51Z</dc:date>
    </item>
    <item>
      <title>Re: Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/6006296#M137401</link>
      <description>&lt;P&gt;Try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(menucmd "M=$(edtime,$(getvar,date),YYYY-MO-DD)")&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps, &lt;BR /&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jan 2016 09:51:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/6006296#M137401</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2016-01-26T09:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/6006441#M137402</link>
      <description>&lt;P&gt;Try changing&lt;/P&gt;&lt;PRE&gt; (menucmd "M=$(edtime,$(getvar,date),YYMD)")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(menucmd "M=$(edtime,$(getvar,date),YY/MO/DD)")&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jan 2016 12:07:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/6006441#M137402</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-01-26T12:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/6022024#M137403</link>
      <description>&lt;P&gt;Thanks to both of you, I changed every code that contained YYMD to YYMODD and it seems to have done the trick!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 15:06:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/6022024#M137403</guid>
      <dc:creator>jens.tornblad</dc:creator>
      <dc:date>2016-02-03T15:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: Save copy of drawing to another folder without xrefs</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/6022035#M137404</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3376665"&gt;@jens.tornblad&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Thanks to both of you, I changed every code that contained YYMD to YYMODD and it seems to have done the trick!&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You're welcome, Jens!&lt;BR /&gt;Glad you got a solution!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Wed, 03 Feb 2016 15:10:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/save-copy-of-drawing-to-another-folder-without-xrefs/m-p/6022035#M137404</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2016-02-03T15:10:43Z</dc:date>
    </item>
  </channel>
</rss>

