russell84 Posted June 10, 2009 Posted June 10, 2009 using lisp does anyone know how to search all folders in a drive for .dwl files?? Quote
Lee Mac Posted June 10, 2009 Posted June 10, 2009 Something like this maybe? (defun fSearch (dir ext) (vl-load-com) (if (vl-file-directory-p dir) (vl-directory-files dir (strcat "*." ext)))) Quote
russell84 Posted June 10, 2009 Author Posted June 10, 2009 Lee Mac - Thank you That works when you specify the specific directory. But does anyone know if it is possible to search all directories within a Drive say "C:" ?? Quote
Lee Mac Posted June 10, 2009 Posted June 10, 2009 I was thinking something like this (inspiration from Jeff Mishler): (defun fSearch (Dir Ext Subf / files Subs) (vl-load-com) (if (vl-file-directory-p Dir) (progn (setq files (vl-directory-files Dir (strcat "*." Ext))) (if (and Subf (setq Subs (vl-directory-files Dir "*" -1) Subs (vl-remove "." Subs) Subs (vl-remove ".." Subs))) (foreach Sub Subs (fSearch (strcat Dir Sub) Ext Subf))) (if files (setq *files* (append *files* files)))))) (defun c:test (/ *files*) (setq *files* '()) (fSearch "C:\\" "dwl" T) (alert (vl-princ-to-string *files*))) Quote
russell84 Posted June 11, 2009 Author Posted June 11, 2009 I see where you are going with that - its a great start - i'll have a look at it and try to work it out - at the moment it is returning nil. Does it work at your end?? Quote
Lee Mac Posted June 11, 2009 Posted June 11, 2009 Just tested - it returns nil my end too Will look into it Quote
Lee Mac Posted June 11, 2009 Posted June 11, 2009 It seems to only go through one level of folders Quote
Lee Mac Posted June 11, 2009 Posted June 11, 2009 This may help you: http://www.theswamp.org/index.php?topic=8427.0 Quote
russell84 Posted June 11, 2009 Author Posted June 11, 2009 Lee mac this works and cycles through folders. You could search for any type of file. It works slow with using an entire drive. I need to set up something so i can see what drawings are currently opened. (defun c:test (/ *files*) (setq *files* '()) (fSearch "C:\\" "dwl" T) (alert (vl-princ-to-string *files*))) (defun fSearch (Dir Ext Subf / files Subs) ;(alert (strcat "Directory = " dir)) (vl-load-com) (if (vl-file-directory-p Dir) (progn (setq files (vl-directory-files Dir (strcat "*." Ext))) (if (and Subf (setq Subs (vl-directory-files Dir nil -1) Subs (vl-remove "." Subs) Subs (vl-remove ".." Subs))) (foreach itm Subs (fSearch (strcat Dir "\\" itm) Ext Subf))) (if files (setq *files* (append *files* files )))))) Quote
russell84 Posted June 11, 2009 Author Posted June 11, 2009 i was using these two snippets of code that i think Asmi helped me with ages ago.The code is loaded automatically on everyones acad in this office. But i just need to work out how to compare the spreadsheets to see what drawings are still open and by what user. It just makes things a lot easier to manage when you have such a large design and drafting team. If you know of any way to create a list of what drawings are currently open by which user would you please let me know. Cheers ;################################################################## ;ON OPEN ;################################################################## (defun-q S::STARTUP (/ Draftername Job file line2write) (setq p1 (strcat (menucmd "M=$(edtime,$(getvar,date),MON - DDD D YY )"))) (setq Draftername (getvar "loginname")) (setq Job (strcat (getvar "dwgprefix") (getvar "dwgname"))) (setq LogOpendatefile (open (strcat "R:\\Temp\\Russell\\DWGLOG\\" p1 "CADCivilDrawingLog.csv") "a")) (setq line2write (strcat Draftername "," (menucmd "M=$(edtime,$(getvar,date),HH:MM AM/PM)") "," "Opened" "," Job)) (write-line line2write LogOpendatefile) (close LogOpendatefile) (Setq dwglogopen (open "R:\\Temp\\Russell\\DWGLOG\\~CADCivilOpenDwgsOverall.csv" "a")) (setq line2writeOverall (strcat Draftername "," (menucmd "M=$(edtime,$(getvar,date),MON D YY HH:MM AM/PM)") "," "Closed" "," Job)) (write-line line2writeOverall dwglogopen) (close dwglogopen) (setq userfile (open (strcat "C:\\" p1 "AutocadCivilUserDrawingLog.csv") "a")) (write-line line2write userfile) (close userfile) (princ)) ;################################################################## ;ON CLOSE ;################################################################## (defun Create_Close_Reactor() (vl-load-com) (if(not close:reactor) (setq close:reactor (vlr-editor-reactor nil '((:vlr-beginClose . CloseReaction)))) ); end if (princ) ); end of Create_Close_Reactor (defun CloseReaction(args reac / actDoc) (setq p1 (strcat (menucmd "M=$(edtime,$(getvar,date),MON - DDD D YY )"))) (setq Draftername (getvar "loginname")) (setq Job (strcat (getvar "dwgprefix") (getvar "dwgname"))) (setq LogCloseddatefile (open (strcat "R:\\Temp\\Russell\\DWGLOG\\" p1 "CADCivilDrawingLog.csv") "a")) (setq line2write (strcat Draftername "," (menucmd "M=$(edtime,$(getvar,date),HH:MM AM/PM)") "," "Closed" "," Job)) (write-line line2write LogCloseddatefile) (close LogCloseddatefile) (Setq dwglogClosed (open "R:\\Temp\\Russell\\DWGLOG\\~CADCivilClosedDwgsOverall.csv" "a")) (setq line2writeOverall (strcat Draftername "," (menucmd "M=$(edtime,$(getvar,date),MON D YY HH:MM AM/PM)") "," "Closed" "," Job)) (write-line line2writeOverall dwglogClosed) (close dwglogClosed) (setq userfile (open (strcat "C:\\" p1 "AutocadCivilUserDrawingLog.csv") "a")) (write-line line2write userfile) (close userfile) (princ) ); end of CloseReaction (Create_Close_Reactor) Quote
Recommended Posts
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.