Jump to content

The Dir command


Irish

Recommended Posts

Hi! new to the forum. I am learning lisp. Hopefully I can someday give back what I learn here with you guys and gals.

 

The afralisp tutorial talks about using the dir command to make a list of drawings in a folder.

 

Command: (command "dir" " /b *.* >temp.txt")

 

first, How do I set dir to my corrent working directory? do I need to have a cmd window open?

Second, how do I take the drawings temp.txt and open it 1 by 1.

 

right now I am using the (command "filedia" "0") and then

(command "open")

but that does not work.

Link to comment
Share on other sites

To view the contents of a folder (used to be called a directory) the old DIR command was used. For example, to view the contents of the C:\AutoCAD directory one would type:

 

dir c:\autocad

 

You'll need the complete path to the files you want to see. For example, if your files were in a folder called 2008, under another folder called My Products the path would be:

 

dir c:\myprojects\2008

 

If you have more than a screen full of files to view at a time you could use the /p switch to pause one screen at a time. Thus, you would have:

 

dir c:\myprojects\2008 /p

 

Just thinking. Would this work with any of the new operating systems like Vista or XP? It's been a long time since I used DOS commands. Maybe you would have to open a command window first now that I think about it.

Link to comment
Share on other sites

Just thinking. Would this work with any of the new operating systems like Vista or XP? It's been a long time since I used DOS commands. Maybe you would have to open a command window first now that I think about it.

it does work with XP and Vista, I use this every day for writing scripts. I can useally write a script in under 3 minutes for any number of drawings, from 10 to 1000. I add some switchs to the command though. (which I will talk about in a minute)

 

  1. Open a command window (referred to as DOS from here on out)
  2. Change to the directory you wish to process using CD (change directory) ie CD H: would change to the H Drive (assuming it exists)
  3. DOS should say H:> at which point you could continure changing to subfolders like CD MyProjects followed by CD 2008 or instead of the 2 steps, CD MyProjects\2008 as a 1 step.
  4. DOS should read H:\MyProjects\2008> at which point you can now create the txt file. At this point, you must decide how you want to access the file ie Are you making a scr file, are you making a data file that other code will open and process the files within, or what have you. Assuming you want to make a script file, type DIR *.dwg /b/s > filename.scr
  5. The /B strips the file name to BARE mode which is only the file name and extension.
  6. The /S adds the subdirectory to the filename which is good for script files as you have the full path right there.
  7. The > is a redirector whcih tells DOS to redirect the normal screen input to somewhere else, in this case a file. Other redirects could be LPT1, whcih would make a print of the info (assuming you have a LPT1 connected)
  8. Now the fun begins. Do a search and replace to make your script and your done

Link to comment
Share on other sites

Look here to open a file

http://cadtutor.net/forum/showthread.php?t=26732&highlight=open+file

 

 

To get a file use

Prompts the user for a file name with the standard AutoCAD file dialog box, and returns that file name

(getfiled title default ext flags)

 

The getfiled function displays a dialog box containing a list of available files of a specified extension type. You can use this dialog box to browse through different drives and directories, select an existing file, or specify the name of a new file.

Link to comment
Share on other sites

AutoLISP has standard function VL-DIRECTORY-FILES which return list of files inside directory specified and filename wildcard pattern specified.

Link to comment
Share on other sites

 
(defun C:GETDIR ( / )
; (setq adwg ".dwg")
(command "filedia" "0")
(setq rpwf (vl-directory-files (GETVAR "DWGPREFIX") "*.dwg" 1))
(setq path (getvar "DWGPREFIX"))
(foreach rfi rpwf
(setq filec (strcat path rfi))
(vla-open (vla-get-documents
(vla-get-application (vlax-get-acad-object))
)
filec)
(getint "press enter")
)
)

We kick butt!8)

 

Thank you people!

Link to comment
Share on other sites

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