Jump to content

Copying and overwriting a Folder based upon date modified


Recommended Posts

Posted

I am trying to figure out how to copy and overwrite a folder based upon the last dated modified utilizing Lee's Copy Folder.

 

I look around and found this code, but not sure how to adapt it for a folder comparison.

 

https://www.cadtutor.net/forum/topic/70116-corona-virus-update-folders-server-to-home-help/

(vl-load-com)

(defun LM:copyfolder ( src des ovr / fso rtn )
    (if (setq fso (vlax-create-object "scripting.filesystemobject"))
        (progn
            (setq rtn
                (not
                    (or (zerop (vlax-invoke fso 'folderexists src))
                        (vl-catch-all-error-p
                            (vl-catch-all-apply 'vlax-invoke
                                (list fso 'copyfolder src des (if ovr :vlax-true :vlax-false))
                            )
                        )
                    )
                )
            )
            (vlax-release-object fso)
            rtn
        )
    )
)


(defun c:comparefoldertest ( / FSO localfolder oldfolder)

      (setq localfolder (findfile "SPI_Ribbon.cuix") ;;Can it look at the folder date instead of file file?
            localfolder (vl-filename-directory localfolder)
            oldfolder (strcat localfolder "_alt"))

      (cond (*akttoday*
              (alert "Please restart AutoCAD and update again.")
              (exit))
            ((vl-file-directory-p oldfolder)
              (setq FSO (vlax-create-object "Scripting.FileSystemObject"))
              (vlax-invoke FSO "DeleteFolder" oldfolder :vlax-true)
              (vlax-release-object FSO))  
      )

      (cond ((and (not *akttoday*)(vl-file-directory-p localfolder))
              (setq *akttoday* 1)
              (vl-file-rename (strcat localfolder "\\") (strcat oldfolder "\\"))

              (LM:copyfolder "L:\\CAD\\AutoCAD\\AutoCAD_SPI_Ribbon" localfolder T)

              (alert "Ribbon updated sucessfully. Menu changes only available after restarting AutoCAD. "))

            (*akttoday*)
            (T (alert "Folder -->  \"AutoCAD_SPI_Ribbon\" \nWas not found!"))
      )

  (prin1)
) ; end of defun

 

Hope this makes sense. Thanks for any ideas.

 

Posted (edited)

The world of google !!! Just had to know what to look for. 

 

Download DOSLIB for Autocad or Bricscad

 

(dos_filedate "D:/acadtemp")

(("Acadtemp" . 20210902.17015))

Edited by BIGAL

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...