Create folder in "C" Partition

Create folder in "C" Partition

hanywillim
Enthusiast Enthusiast
1,187 Views
9 Replies
Message 1 of 10

Create folder in "C" Partition

hanywillim
Enthusiast
Enthusiast

i work with main lisp to create a folder on desktop and save drawings in it , now i want to create this folder in C partition:

(setq desktop-dir (strcat (getenv "USERPROFILE") "\\Desktop"))
(vl-mkdir (strcat desktop-dir "\\Cleaned Drawings\\"))
(command "_.SAVEAS" "" (strcat desktop-dir "\\Cleaned Drawings\\" (nth n Files_Folder)) "_Yes")

 Now need to create the folder in this path:
C:\My folder\Cleaned Drawings

Thanks in advance

0 Likes
1,188 Views
9 Replies
Replies (9)
Message 2 of 10

paullimapa
Mentor
Mentor
(setq desktop-dir "C:\\My Folder")
(vl-mkdir (strcat desktop-dir "\\Cleaned Drawings\\"))
(command "_.SAVEAS" "" (strcat desktop-dir "\\Cleaned Drawings\\" (nth n Files_Folder)) "_Yes")

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 10

hanywillim
Enthusiast
Enthusiast

i run the lisp but get this error:
Path does not exist: C:\My Folder\Cleaned Drawings\
Please verify the correct path was given.

and checked partition "C" there is no folders created yet
i think maybe need a permission to create folder in C or it is something else?

0 Likes
Message 4 of 10

paullimapa
Mentor
Mentor

You can test to see if this fails to create folder by pasting directly onto AutoCAD command line. Like you stated you may not have permissions to create this on C: since it’s not inside your windows profile 

(setq desktop-dir "C:\\My Folder")
(vl-mkdir (strcat desktop-dir "\\Cleaned Drawings\\"))

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 10

hanywillim
Enthusiast
Enthusiast

But i need the code to create the "My Folder" if it is not exist 

0 Likes
Message 6 of 10

paullimapa
Mentor
Mentor

But like you said you may not have permissions to create this on your C: drive

Perhaps another way to test is to run Windows Explorer and see if you’re successful in creating My Folder in C:


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 7 of 10

Sea-Haven
Mentor
Mentor

Just test 1st level. Copy and paste to command line.

 

 

(vl-mkdir "C:\\My Folder")

 

  

Message 8 of 10

hanywillim
Enthusiast
Enthusiast

it is work 
should i create each folder first by using separated line code like this, or i can create all the path once?

0 Likes
Message 9 of 10

Sea-Haven
Mentor
Mentor

I tried to make a big sub directory not working. Looks like mkdir only makes 1 level. Maybe try running Mkdir multi times. The other way is using Shell and you can use the old fashioned DOS command MD your directory.

 

 

(command "._shell" "MD d:\\localjobs\\fs\\LCFC3\\DESIGN\\DATA")

 

Message 10 of 10

Michiel.Valcke
Advisor
Advisor

vl-mkdir can only make one directory at the time, feed it a list of directories and loop through it to make deeper paths

You can do something like this:

(defun MakeMultiDir ( lst / dir)
	(foreach x lst
		(if dir
			(setq dir (strcat dir "\\" x))
			(setq dir x)
        )
		(vl-mkdir dir)
	)
	(princ)
)

(defun c:testmakemultidir ( / )
	(MakeMultiDir (list "c:\\test" "make" "multiple" "directories"))
	(princ)
)

 

MichielValcke_0-1692690363337.png

 



0 Likes