Jump to content
Sambuddy

Corona Virus - update folders server to home help

Recommended Posts

Sambuddy

@Lee Mac

hopefully you can answer me in your earliest convenience as almost everyone is moving from offices to homes, I am trying to find a way to update PCs.

Basically, the overwrite function does not seem to work for me - if I make an update, I am trying to have to so that it updates the files and folders but it does not seem to be happening. I have been twitching this routine but still having the same problem. It does work when I do not have the initial folder but when it exists, it just does not overwrite it. Could you please help!

 

Thanks,

As you can see, I am trying to update if "Update CADSET.txt" is updated to then overwrite TX Cad Config folder from T to C drives and overwrite everything (folders and files).

 

Please help

(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
        )
    )
); END DEFUN
(vl-load-com)

;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;;

;;; NEWER OR OLDER CONDITION
(defun newer-p ( f1 f2 / compare )

    (defun compare ( a b )
        (cond
            (   (> (car a) (car b)))
            (   (and a b (= (car a) (car b)))
                (compare (cdr a) (cdr b))
            )
        )
    )

    (apply 'compare
        (mapcar '(lambda ( x ) (vl-list* (car x) (cadr x) (cdddr x)))
            (mapcar 'vl-file-systime (list f1 f2))
        )
    )
) ;END DEFUN

;; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ;;

	(setq f1 (findfile "T:\\SALLE A DESSIN\\Outils CAD\\Outils configuration\\TX Cad Config\\UPDATE CADSET.txt")) ; source file
      	(setq f2 (findfile "C:\\TX Cad Config\\UPDATE CADSET.txt")) ; destination file
			(if (newer-p f1 f2) ; if f1 is newer than f2 then
			(LM:copyfolder "T:\\SALLE A DESSIN\\Outils CAD\\Outils configuration\\TX Cad Config" "C:\\TX Cad Config" ovr) ; copy from T to C drive
  			(princ "\nUpdate is not available - No action taken! \nLa mise à jour n'est pas disponible pour le moment") ; if NOT, then show this message
		) ;END IF
		(princ "this is the next line after update")
  		(princ)

  

this is what I found on https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/copy-folder-lee-mac/td-p/7557504

(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 spi:update ( / FSO localfolder oldfolder)

      (setq localfolder (findfile "SPI_Ribbon.cuix")
            localfolder (vl-filename-directory localfolder)
            oldfolder (strcat localfolder "_alt"))

      (cond (*akttoday*
              (alert "Bitte AutoCAD neustarten und nochmals aktualisieren!")
              (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 "P:\\CAD\\AutoCAD\\AutoCAD_SPI_Ribbon" localfolder T)
              (alert "Ribbon erfolgreich aktualisiert! \n\nMenüänderungen erst nach AutoCAD-Neustart vorhanden."))
            (*akttoday*)
            (T (alert "Ordner -->  \"AutoCAD_SPI_Ribbon\" \nwurde nicht gefunden!"))
      )

  (prin1)
) ; end of defun

Share this post


Link to post
Share on other sites
BIGAL

You can set up remote access to a server so "T" drive still exists. You will need software both ends, I have used VPN and it was very fast working from home. Not set up by me had an IT department.

Share this post


Link to post
Share on other sites
Sambuddy
1 hour ago, BIGAL said:

You can set up remote access to a server so "T" drive still exists. You will need software both ends, I have used VPN and it was very fast working from home. Not set up by me had an IT department.

@BIGAL

I thank you for responding to my inquiries every time - you are GREAT BIGAL!

 

Is there a way you could take a quick look at the routine above and see if there is a way to fix that? The problem I have with VPN is the bandwidth and data transfer rate. I was hoping to test this as an alternative option since I do not know how long this problem would insist with us being away. There are some files that need to be updated and reside on local drive to avoid everyone on the network trying to access them and as a result crappy speed. I think you are in Australia with better services. I am in Canada with crap but expensive services.

 

could you please help me out with either code above?

 

thank you

Share this post


Link to post
Share on other sites
BIGAL

You should not have to ping the server all the time once you download your core data, mnu's etc even inserting a remote dwg every one would not be doing at same time, set paths like temp directory to c drive so temp files are not sent to the server. Some old DOS commands can come in handy like Xcopy for directories ran via "shell" command.

 

We had some laptops and they had what they needed not necessarily everything if something missing go get it. Whilst not ideal copy to C then work on it, then save back. May be faster than working real time of server.

Share this post


Link to post
Share on other sites
Sambuddy
3 hours ago, BIGAL said:

You should not have to ping the server all the time once you download your core data, mnu's etc even inserting a remote dwg every one would not be doing at same time, set paths like temp directory to c drive so temp files are not sent to the server. Some old DOS commands can come in handy like Xcopy for directories ran via "shell" command.

 

We had some laptops and they had what they needed not necessarily everything if something missing go get it. Whilst not ideal copy to C then work on it, then save back. May be faster than working real time of server.


before using Lee Mac’s, I was using shell command. Two problems: I had to create directory for the files each time to be copied and I could never bypass the question each time asking if I am sure I want to copy an existing file (imagine asking this 100 times when using copy on shell). I just did not know how to override without prompt.

 

Lee Mac’s copy folder does wonder but I cannot seem to get it to override the existing files and folders! Can you help please?

Share this post


Link to post
Share on other sites
Roy_043

@Sambuddy

Have you tried to change this portion?:

(zerop (vlax-invoke fso 'folderexists src))

Share this post


Link to post
Share on other sites
Sambuddy
2 hours ago, Roy_043 said:

@Sambuddy

Have you tried to change this portion?:


(zerop (vlax-invoke fso 'folderexists src))

Hey Roy, not sure what to do here!

Any ideas if I want to override all the content, folder, sub-folder and files under a directory?

Not sure what to do with this line!!!

Thanks

Share this post


Link to post
Share on other sites
Roy_043

Actually the LM:copyfolder code seems to work just fine. I misread it.

 

In your code you have:

(LM:copyfolder "T:\\SALLE A DESSIN\\Outils CAD\\Outils configuration\\TX Cad Config" "C:\\TX Cad Config" ovr)

Try changing it to:

(LM:copyfolder "T:\\SALLE A DESSIN\\Outils CAD\\Outils configuration\\TX Cad Config" "C:\\TX Cad Config" T)

 

Share this post


Link to post
Share on other sites
Sambuddy
12 minutes ago, Roy_043 said:

Actually the LM:copyfolder code seems to work just fine. I misread it.

 

In your code you have:


(LM:copyfolder "T:\\SALLE A DESSIN\\Outils CAD\\Outils configuration\\TX Cad Config" "C:\\TX Cad Config" ovr)

Try changing it to:


(LM:copyfolder "T:\\SALLE A DESSIN\\Outils CAD\\Outils configuration\\TX Cad Config" "C:\\TX Cad Config" T)

 

 

It does return NIL - no overriding of files and folders happen!

Share this post


Link to post
Share on other sites
Roy_043

There is something that does not make sense. In your initial post you say that there is no problem if "the initial folder" does not exist. But if either of the two folders ("T:\\SALLE A DESSIN\\Outils CAD\\Outils configuration\\TX Cad Config" and "C:\\TX Cad Config") does not exist f1 or f2 would be nil and (newer-p f1 f2) should fail.

Share this post


Link to post
Share on other sites
Sambuddy
50 minutes ago, Roy_043 said:

There is something that does not make sense. In your initial post you say that there is no problem if "the initial folder" does not exist. But if either of the two folders ("T:\\SALLE A DESSIN\\Outils CAD\\Outils configuration\\TX Cad Config" and "C:\\TX Cad Config") does not exist f1 or f2 would be nil and (newer-p f1 f2) should fail.

 

That is the second portion when I evaluate a .txt for f1 and f2. This is not a problem. My problem is copying and overriding each time I should say (LM:copyfolder blah blah).

I am now trying to rename the existing and copy from the source but not much success.

 

I uploaded my entire code just so one could make sense of what I am trying to accomplish - I have no issue with f1 f2 evaluation

Share this post


Link to post
Share on other sites
Roy_043

Strange, what you call the second portion, is the first portion of the code that will run.

And you say there is no problem, when I think there in fact must be.

 

Ah well... Maybe somebody else should jump in.

Share this post


Link to post
Share on other sites
Sambuddy

problem solved for now!

 

I am using power Shell in order to rename, copy and delete and override them with /q /s /y!

 

Thanks Roy

Share this post


Link to post
Share on other sites
ronjonp
18 minutes ago, Sambuddy said:

problem solved for now!

 

I am using power Shell in order to rename, copy and delete and override them with /q /s /y!

 

Thanks Roy

You might also look at THIS.

Share this post


Link to post
Share on other sites
BIGAL

Thanks ronjonp another person using xcopy its designed to do mass file stuff. Nice idea lisp front end for choice.

Share this post


Link to post
Share on other sites

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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...