PDA

View Full Version : Is there any way to create a folder via LISP


mpemberton
2006-11-11, 06:34 AM
Is there any way to create a folder thru a lisp routine? I am writing a simple email out lisp to save a copy of the drawing into an "Email Out (Dated Folder" and bind all of the xreference files. However, I don't want to create the folder each time. Attached is what I have finished. Can some one help me? The only real help I NEED is creating the new folder. Unless what I have wrote is really wrong.
Every project already has the Email folder and the Out folder

Email
-Out
11-10-2006
-In


Thank You,
Matt

Mike.Perry
2006-11-11, 08:01 AM
Hi

See THIS post.

Plus, the following thread may interest yourself ( then again it might not )...

Controlling Outlook from AutoCAD

Have a good one, Mike

rkmcswain
2006-11-11, 12:57 PM
Is there any way to create a folder thru a lisp routine? I am writing a simple email out lisp to save a copy of the drawing into an "Email Out (Dated Folder" and bind all of the xreference files. However, I don't want to create the folder each time. Attached is what I have finished. Can some one help me? The only real help I NEED is creating the new folder. Unless what I have wrote is really wrong.
Every project already has the Email folder and the Out folder

Email
-Out
11-10-2006
-In


Thank You,
Matt

Matt,

Just use the (vl-mkdir) function. Unfortunately, it will only create a single child directory on an existing parent. But, this Function (http://groups.google.com/group/autodesk.autocad.customization/msg/eba26cad03b7c6e5?hl=en&), by John Uhden is a good example of how to make it do more.

Using it, you can pass an entire path such as "C:\\Email\\Out\\2006-11-11" and the whole path will be created.

Example: (makepath "C:\\Email\\Out\\2006-11-11")

mpemberton
2006-11-12, 04:22 AM
Thanks guys, I got it all to work, I will give it a try on Monday @ the office. I have attached the finished lisp.

Thank You,
Matt

Terry Cadd
2006-11-13, 09:22 PM
Here is a variation of the MakePath function that allows you to create a folder which might have a period within the folder name.
Syntax: (MakeDir “C:\\Dwgs\\P.M.D.\\RV.7431”)

;-------------------------------------------------------------------------------
; MakeDir - Create new folders
; Arguments: 1
; Pathname$ = Pathname string
; Returns: Creates new folders.
; Syntax: (MakeDir "D:\\ABC\\DEF")
;-------------------------------------------------------------------------------
(defun MakeDir (Pathname$ / Drive$ Folder$ Folders@)
(setq Pathname$ (vl-filename-directory (strcat Pathname$ "\\")))
(while (/= Drive$ Pathname$)
(setq Folder$ (substr Pathname$ (1+ (strlen (vl-filename-directory Pathname$)))))
(if (= (substr Folder$ 1 1) "\\")
(setq Folder$ (substr Folder$ 2))
);if
(setq Folders@ (cons Folder$ Folders@)
Drive$ Pathname$
Pathname$ (vl-filename-directory Pathname$)
);setq
);while
(foreach Folder$ (cdr Folders@)
(vl-mkdir (strcat Pathname$ Folder$))
(setq Pathname$ (strcat Pathname$ Folder$ "\\"))
);foreach
);defun MakeDir

CadDog
2008-06-20, 06:52 AM
Thanks everyone...

I know that I can use this idea and lisps to create something useful...

Keep them flowing...

:)

FRAMEDNLV
2008-06-20, 05:12 PM
This is what I use:
(acet-file-mkdir (strcat (getvar "dwgprefix") "\Out\\"))
(setq DWGNM (strcat (getvar "dwgprefix") "\Out\\"(strcat (GETVAR "DWGNAME" ))))
(COMMAND "saveas" "2004" (setq TM (strcat dwgnm )))

Chris

mikelf
2008-06-24, 09:30 PM
Is it possible to change permissions on a directory with LISP?

rkmcswain
2008-06-25, 12:46 AM
Is it possible to change permissions on a directory with LISP?

I have not done it, but I bet you can since it's exposed via Windows API.

I'll be watching....

03xtreme
2008-06-27, 01:53 PM
we use a .bat routine that creates most of the directories every project needs and you use them or leave them blank. It's pretty sweet and prevents you from having to make any directories except \emai\To-"insertnamehere" and email\From-"insertnamehere"

I can't imagine it is faster to do in cad than it is to do through win explorer, is it?

(just change the attached txt to a .bat, then when you double click on it, it will operate like a program)