Jump to content

Recommended Posts

Posted

Hello everyone:

 

I'm updating some old code of mine and I want to get ride of using the shell command, you know why.

 

I need to create a folder, this is what's written now to create the folder num_br:

 

 

(setq commd (strcat "md " "

Posted

Sorry I tried to post the code twice and failed, you can see i'm obviously newbie. The idea is to use a vl command to create a folder. Which's that command?

Posted

from Developer Help > AutoLISP Reference

vl-mkdir

 

Creates a directory

(vl-mkdir directoryname)

 

Arguments

directoryname

The name of the directory you want to create.

 

Return Values

T if successful, nil if the directory exists or if unsuccessful.

Examples

Create a directory named mydirectory:

_$ (vl-mkdir "c:\\mydirectory”)

T

Posted

vl-mkdir can make a single folder, so this is what I use to create a directory structure:

 

[i][color=#990099];;-------------------=={ Make Directory }==-------------------;;[/color][/i]
[i][color=#990099];;                                                            ;;[/color][/i]
[i][color=#990099];;  Creates a directory structure                             ;;[/color][/i]
[i][color=#990099];;------------------------------------------------------------;;[/color][/i]
[i][color=#990099];;  Author: Lee McDonnell, 2010                               ;;[/color][/i]
[i][color=#990099];;                                                            ;;[/color][/i]
[i][color=#990099];;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;[/color][/i]
[i][color=#990099];;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;[/color][/i]
[i][color=#990099];;------------------------------------------------------------;;[/color][/i]
[i][color=#990099];;  Arguments:                                                ;;[/color][/i]
[i][color=#990099];;  dir - the directory to create                             ;;[/color][/i]
[i][color=#990099];;------------------------------------------------------------;;[/color][/i]
[i][color=#990099];;  Returns:  T if directory creation is successful, else nil ;;[/color][/i]
[i][color=#990099];;------------------------------------------------------------;;[/color][/i]

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] [color=black]LM:MakeDirectory[/color] [b][color=RED]([/color][/b] dir [b][color=BLUE]/[/color][/b] MakeDirectory folders [b][color=RED])[/color][/b]
 [i][color=#990099];; © Lee Mac 2010[/color][/i]
 [i][color=#990099];; (LM:MakeDirectory "C:\\Folder\\Subfolder")[/color][/i]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b]

 [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] MakeDirectory [b][color=RED]([/color][/b] root folders [b][color=RED])[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] folders
     [b][color=RED]([/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]lambda[/color][/b] [b][color=RED]([/color][/b] dir [b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-mkdir[/color][/b] dir[b][color=RED])[/color][/b]
         [b][color=RED]([/color][/b]MakeDirectory dir [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] folders[b][color=RED]))[/color][/b]
       [b][color=RED])[/color][/b]
       [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] root [b][color=#a52a2a]"\\"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] folders[b][color=RED]))[/color][/b]
     [b][color=RED])[/color][/b]
   [b][color=RED])[/color][/b]
 [b][color=RED])[/color][/b]
 
 [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] folders [b][color=RED]([/color][/b][color=black]LM:str->lst[/color] [b][color=RED]([/color][/b][b][color=BLUE]vl-string-translate[/color][/b] [b][color=#a52a2a]"/"[/color][/b] [b][color=#a52a2a]"\\"[/color][/b] dir[b][color=RED])[/color][/b] [b][color=#a52a2a]"\\"[/color][/b][b][color=RED]))[/color][/b]
   [b][color=RED]([/color][/b]MakeDirectory [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] folders[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] folders[b][color=RED]))[/color][/b]
 [b][color=RED])[/color][/b]
 [b][color=RED]([/color][/b][b][color=BLUE]vl-file-directory-p[/color][/b] dir[b][color=RED])[/color][/b]
[b][color=RED])[/color][/b]

[i][color=#990099];;-------------------=={ String -> List }==-------------------;;[/color][/i]
[i][color=#990099];;                                                            ;;[/color][/i]
[i][color=#990099];;  Separates a string into a list of strings using a         ;;[/color][/i]
[i][color=#990099];;  specified delimiter string                                ;;[/color][/i]
[i][color=#990099];;------------------------------------------------------------;;[/color][/i]
[i][color=#990099];;  Author: Lee McDonnell, 2010                               ;;[/color][/i]
[i][color=#990099];;                                                            ;;[/color][/i]
[i][color=#990099];;  Copyright © 2010 by Lee McDonnell, All Rights Reserved.   ;;[/color][/i]
[i][color=#990099];;  Contact: Lee Mac @ TheSwamp.org, CADTutor.net             ;;[/color][/i]
[i][color=#990099];;------------------------------------------------------------;;[/color][/i]
[i][color=#990099];;  Arguments:                                                ;;[/color][/i]
[i][color=#990099];;  str - string to process                                   ;;[/color][/i]
[i][color=#990099];;  del - delimiter by which to separate the string           ;;[/color][/i]
[i][color=#990099];;------------------------------------------------------------;;[/color][/i]
[i][color=#990099];;  Returns:  A list of strings                               ;;[/color][/i]
[i][color=#990099];;------------------------------------------------------------;;[/color][/i]

[b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] [color=black]LM:str->lst[/color] [b][color=RED]([/color][/b] str del [b][color=BLUE]/[/color][/b] pos [b][color=RED])[/color][/b]
 [i][color=#990099];; © Lee Mac 2010[/color][/i]
 [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pos [b][color=RED]([/color][/b][b][color=BLUE]vl-string-search[/color][/b] del str[b][color=RED]))[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]substr[/color][/b] str [b][color=#009900]1[/color][/b] pos[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][color=black]LM:str->lst[/color] [b][color=RED]([/color][/b][b][color=BLUE]substr[/color][/b] str [b][color=RED]([/color][/b][b][color=BLUE]+[/color][/b] pos [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strlen[/color][/b] del[b][color=RED])))[/color][/b] del[b][color=RED]))[/color][/b]
   [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] str[b][color=RED])[/color][/b]
 [b][color=RED])[/color][/b]
[b][color=RED])[/color][/b]

Posted

Thank you very much, it is working perfectly as I wanted.

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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