Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delete folder command

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
nn.araujo
2229 Views, 4 Replies

Delete folder command

Hi everybody

 

I need to delete a folder (not empty) in my LISP routine and I’m not being able to do so. I created the folder using (vl-mkdir “foldername”) but I don’t find the equivalent command to remove it. Any help?

 

Thanks

Nuno

4 REPLIES 4
Message 2 of 5
JustoAg
in reply to: nn.araujo

This delete the folder and its content:

(setq FSO (vlax-create-object "Scripting.FileSystemObject"))
(vlax-invoke FSO "DeleteFolder" "D:\\folder1\\folder2\\Prog\\AutoLISP\\deletme" :vlax-true)

at the end release the FSO:

(vlax-release-object FSO)

 

Hope this helps.

 

Justo Aguiar.

Message 3 of 5
nn.araujo
in reply to: nn.araujo

Hello Just Aguiar,

 

It works perfectly. I just change from absolute path to local path (vlax-invoke FSO "DeleteFolder" ".\\foldername" :vlax-true). Problem solved!

 

Thanks

Nuno

Message 4 of 5
anovelli
in reply to: nn.araujo

Any way to use a while card?

 

I want to delete all the Background Plot folders.

 

For me they are created in C:\Temp\BGPlot_2552 but the number varies.

 

Please let me know.

Message 5 of 5
rkmcswain
in reply to: anovelli

anovelli wrote:

Any way to use a while card?

I want to delete all the Background Plot folders.

For me they are created in C:\Temp\BGPlot_2552 but the number varies.

I'm presuming you mean "wild" card.

In that case, give this a try:

 

;;;;~~~~~~~~~~~~~~~~~~~~~~~~~~~
(setq temp (getenv "temp"))
(if (setq k3 (vl-directory-files temp "BGPlot_*" -1))
  (progn
    (setq fso (vlax-create-object "Scripting.FileSystemObject"))
    (foreach x k3
      (vlax-invoke-method fso 'DeleteFolder (strcat temp "\\" x)  :vlax-false)
      (princ (strcat "\nDeleted folder [" x "]"))
    )
    (vlax-release-object fso)
  )
  (princ)
)  
;;;;~~~~~~~~~~~~~~~~~~~~~~~~~~~
R.K. McSwain     | CADpanacea | on twitter

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost