Author Topic: List Sub-Directories within a Directory  (Read 12013 times)

0 Members and 2 Guests are viewing this topic.

deegeecees

  • Guest
Re: List Sub-Directories within a Directory
« Reply #15 on: August 21, 2012, 12:16:15 PM »
FWIW here's what I got working, it ain't pretty but it works:

Code: [Select]
;dir_list2.lsp
;Created for AFTS by P.R. Donnelly
;Date: Aug of 2012
;Description: Lists subdirectories in a given directory
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;start prog

(DEFUN C:dir_list2 ()

;;;;;;;;;;;;;;;;;;;;;;;;;Select directory to be processed

(setq dfil (getfiled "Select a **FILE** in the directory you want to list, then click on OPEN" "y:/" "*" 0))
(setq wutdir (vl-filename-directory dfil))
(setq wutfiles (vl-directory-files wutdir nil -1))
(setq dwglistfile (strcat wutdir "\\dir_list2.txt"))
(SETQ dwgfiler (OPEN dwglistfile "w"))
(WRITE-LINE wutdir dwgfiler)
(foreach n wutfiles
(WRITE-LINE n dwgfiler)
(princ)
)
(alert "\n***File DIR_LIST2.TXT has been created in the directory you chose.***")
(CLOSE dwgfiler)
(startapp "notepad" dwglistfile)


(princ)


);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DEFUN

PKENEWELL

  • Bull Frog
  • Posts: 319
Re: List Sub-Directories within a Directory
« Reply #16 on: August 21, 2012, 02:49:56 PM »
Suggestion: Replace your (getfiled) call to get the folder with this:

Code - Auto/Visual Lisp: [Select]
  1. ;|==============================================================================
  2.   Function Name: (pjk-FolderBrowseDialog)
  3.   Arguments:
  4.      msg = String; A Title Message to Display in the Browse Dialog.
  5.      dir = String; Path to start in (NIL for current)
  6.      flag = Integer; Options flags bit code for the Dialog display options
  7.          0 = Standard behaviour (Default)
  8.          1 = Only file system folders can be selected. If this bit is set, the OK button is disabled if the user selects a folder that doesn't belong to the file system.
  9.          2 = The user is prohibited from browsing below the domain within a network
  10.          4 = Room for status text is provided under the dialog box
  11.          8 = Returns file system ancestors only. An ancestor is a subfolder that is beneath the root folder. If the user selects an ancestor of the root folder that is not part of the file system, the OK button is grayed.
  12.          16 = Shows an edit box in the dialog box for the user to type the name of an item.
  13.          32 = Validate the name typed in the edit box.
  14.          64 = Enable drag-and-drop capability within the dialog box, reordering, shortcut menus, new folders, delete, and other shortcut menu commands.
  15.          128 = The browse dialog box can display URLs.
  16.          256 = When combined with flag 64, adds a usage hint to the dialog box, in place of the edit box.
  17.          512 = Suppresses display of the 'New Folder' button
  18.          1024 = When the selected item is a shortcut, return the PIDL of the shortcut itself rather than its target.
  19.          4096 = Enables the user to browse the network branch for computer names. If the user selects anything other than a computer, the OK button is grayed.
  20.          8192 = Enables the user to browse the network branch for printer names. If the user selects anything other than a printer, the OK button is grayed.
  21.          16384 = Allows browsing for everything: the browse dialog box displays files as well as folders.
  22.          32768 = If combined with flag 64, the browse dialog box can display shareable resources on remote systems.
  23.          65536 = Windows7 & later: Allow folder junctions such as a library or a compressed file with a .zip file name extension to be browsed.
  24.   Usage: (pjk-FolderBrowseDialog <msg> [dir] <flag>)
  25.   Returns: Selected Directory, else nil if user presses Cancel
  26.   Description:
  27.        Utilizes the BrowseForFolder method in the Shell Object to provide a dialog interface through which the user may select directory.
  28.  
  29.   My thanks and credit for this code goes to (Original Header Below):
  30.  ;;-------------------=={ Directory Dialog }==-----------------;;
  31. ;;                                                            ;;
  32. ;;  Displays a dialog prompting the user to select a folder   ;;
  33. ;;------------------------------------------------------------;;
  34. ;;  Author: Lee Mac, Copyright © 2011 - www.lee-mac.com       ;;
  35. ;;------------------------------------------------------------;;
  36. ;;  Arguments:                                                ;;
  37. ;;  msg  - message to display at top of dialog                ;;
  38. ;;  dir  - root directory (or nil)                            ;;
  39. ;;  flag - bit coded flag specifying dialog display settings  ;;
  40. ;;------------------------------------------------------------;;
  41. ;;  Returns:  Selected folder filepath, else nil              ;;
  42. ;;------------------------------------------------------------;;
  43. Altered: Changed name of function for consistency with my personal "pjk-utilities.lsp"
  44. ================================================================================|;
  45. (defun pjk-FolderBrowseDialog (msg dir flag / Shell Fold Self Path )
  46.   (vl-catch-all-apply
  47.     (function
  48.       (lambda ( / ac HWND )
  49.         (if
  50.           (setq Shell (vla-getInterfaceObject (setq ac (vlax-get-acad-object)) "Shell.Application")
  51.                 HWND  (vl-catch-all-apply 'vla-get-HWND (list ac))
  52.                 Fold  (vlax-invoke-method Shell 'BrowseForFolder (if (vl-catch-all-error-p HWND) 0 HWND) msg flag dir)
  53.           )
  54.           (setq Self (vlax-get-property Fold 'Self)
  55.                 Path (vlax-get-property Self 'Path)
  56.                 Path (vl-string-right-trim "\\" (vl-string-translate "/" "\\" Path))
  57.           )
  58.         )
  59.       )
  60.     )
  61.   )
  62.   (if Self  (vlax-release-object  Self))
  63.   (if Fold  (vlax-release-object  Fold))
  64.   (if Shell (vlax-release-object Shell))
  65.   Path
  66. );; End Function (pjk-FolderBrowseDialog)
  67.  
  68. ;; Example:
  69. (pjk-FolderBrowseDialog "Select a Folder for your file:" "C:" 0)
  70.  

The you wouldn't need to strip the file off and it would be more user friendly.

EDIT: In my ignorance I did not give credit to the original Author. This is Lee Mac's code - My apologies for not including his name in the Header of this code. I have rectified the above code to include his copyright and my thanks.
« Last Edit: August 23, 2012, 12:03:28 PM by PKENEWELL »
"When you are asked if you can do a job, tell 'em, 'Certainly I can!' Then get busy and find out how to do it." - Theodore Roosevelt

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: List Sub-Directories within a Directory
« Reply #17 on: August 21, 2012, 03:31:43 PM »
Seriously?

copy/paste my code and rename it as your own?

chlh_jd

  • Guest
Re: List Sub-Directories within a Directory
« Reply #18 on: August 21, 2012, 03:45:59 PM »
Exactly like the real thing  :pissed:

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: List Sub-Directories within a Directory
« Reply #19 on: August 21, 2012, 04:10:23 PM »
Its people like you PKENEWELL that make me wonder why I even bother sharing my code at all.

For all the effort and time that I invest in updating my site, I only ask that the headers and author accreditation are retained where my code is used, and you have the sheer audacity to strip my name entirely from my code and bluntly claim it as your own - hell, you couldn't even be bothered to write your own description but had to steal that from my site too.

Well, what can I say - don't expect any help from me if ever you post a question to this forum, and I doubt the community here will now be queuing to lend you a hand.

chlh_jd

  • Guest
Re: List Sub-Directories within a Directory
« Reply #20 on: August 21, 2012, 04:29:41 PM »
Its people like you PKENEWELL that make me wonder why I even bother sharing my code at all.

For all the effort and time that I invest in updating my site, I only ask that the headers and author accreditation are retained where my code is used, and you have the sheer audacity to strip my name entirely from my code and bluntly claim it as your own - hell, you couldn't even be bothered to write your own description but had to steal that from my site too.

Well, what can I say - don't expect any help from me if ever you post a question to this forum, and I doubt the community here will now be queuing to lend you a hand.

Hi Lee Mac
I very much agree with you, should be respected author .
Villain everywhere, so long as we recognize your achievements .
The indisputable fact that will make everyone hate thieves , but we need first to find out his source code, perhaps  copy  from your site several hand .
So you also don't despair , time will tell .
I must sleep , Good bye Lee .

owenwengerd

  • Bull Frog
  • Posts: 451
Re: List Sub-Directories within a Directory
« Reply #21 on: August 21, 2012, 04:44:09 PM »
Its people like you PKENEWELL that make me wonder why I even bother sharing my code at all.

Public shaming is good, but you also need to send a DMCA takedown notice to Mark and get the stolen content removed.

LE3

  • Guest
Re: List Sub-Directories within a Directory
« Reply #22 on: August 21, 2012, 05:32:41 PM »
Its people like you PKENEWELL that make me wonder why I even bother sharing my code at all.

For all the effort and time that I invest in updating my site, I only ask that the headers and author accreditation are retained where my code is used, and you have the sheer audacity to strip my name entirely from my code and bluntly claim it as your own - hell, you couldn't even be bothered to write your own description but had to steal that from my site too.

Well, what can I say - don't expect any help from me if ever you post a question to this forum, and I doubt the community here will now be queuing to lend you a hand.

What a f... indeed.... that's no joke...
 
Here it is something I wrote about 12 years ago... geez getting older:
http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Search-Sub-folders/td-p/889427

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: List Sub-Directories within a Directory
« Reply #23 on: August 21, 2012, 05:41:27 PM »
Lee my friend, you know I'm supportive of your efforts to share code and educate the community, but is there a chance this is not a case of plagerism? The underlying algorythm has been done many times by many different authors, each translating MSDN code to LISP. There's only so many variants for such a small code snip that can be penned, none of them would appear all that unique. The header information, i.e. flag states etc. too originates from MSDN if I'm not mistaken.

Just saying.

If there's blatant plagerism I support your want to have a wrong fixed, but I'm highly doubtful -- Mr. Kenewell has been around a long time, and I have no reason to think he would need to lift another's code, passing it off as his.

Sincerely, Michael.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: List Sub-Directories within a Directory
« Reply #24 on: August 21, 2012, 05:55:43 PM »
Lee my friend, you know I'm supportive of your efforts to share code and educate the community, but is there a chance this is not a case of plagerism? The underlying algorythm has been done many times by many different authors, each translating MSDN code to LISP. There's only so many variants for such a small code snip that can be penned, none of them would appear all that unique. The header information, i.e. flag states etc. too originates from MSDN if I'm not mistaken.

Just saying.

If there's blatant plagerism I support your want to have a wrong fixed, but I'm highly doubtful -- Mr. Kenewell has been around a long time, and I have no reason to think he would need to lift another's code, passing it off as his.

Sincerely, Michael.

I'm certainly prepared to give the benefit of the doubt in most cases, as I agree wholeheartedly that the underlying methods of almost everything I write have been demonstrated long before I even started coding (which wasn't too long ago in any case). Even for the function concerned, Tony T has posted similar functions in the past which use the same method.

However, in this particular case it is absolutely clear that the code is a result of a straight copy/paste - compare the above with the code and description as published on my site - every line of the code and even the code formatting is identical. The usage note in PKENEWELL's header is identical to the 'Function Syntax' on my site (with my initials removed of course); the 'Returns' in the header is identical to that stated on my site - word-for-word; even the 'Description' is word-for-word from my site - the grammatical error at the end is even included!: "through which the user may select [a] directory."

Coincidence? I think not.
« Last Edit: August 21, 2012, 07:20:23 PM by Lee Mac »

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: List Sub-Directories within a Directory
« Reply #25 on: August 21, 2012, 06:01:31 PM »
I must confess I did not review the code line for line as I'm swamped. If what you assert is true it's extremely dissappointing and you have every right to be incensed -- and I support your right and want to have the offending code taken down.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: List Sub-Directories within a Directory
« Reply #26 on: August 21, 2012, 06:10:58 PM »
Lee,

I think we all 'stole' some LISP code since the pionneers (as Reini Urban, Vladimir Nesterovsky, ...).

What should I say when I see in your Mathematical Functions exactly the same defun names for dot product (vxv) and cross product (v^v) as those I wrote in 2005 ?
Why does an English guy uses the quite now obsolete French math symbols for these functions ?
Speaking English as a French Frog

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: List Sub-Directories within a Directory
« Reply #27 on: August 21, 2012, 06:23:41 PM »
Lee,

I think we all 'stole' some LISP code since the pionneers (as Reini Urban, Vladimir Nesterovsky, ...).

What should I say when I see in your Mathematical Functions exactly the same defun names for dot product (vxv) and cross product (v^v) as those I wrote in 2005 ?
Why does an English guy uses the quite now obsolete French math symbols for these functions ?

gile,

I'm not sure what you mean by the 'obsolete French math symbols', but I do try my utmost to give credit where it's due and will always look to correct any inadvertent plagiarism (as I have with rightful accreditation to the 'trp', 'mxm' and 'mxv' functions)

I can assure you that I have independently written the other vector functions when adding them to my site (I'm not sure how else I could have written them) and followed the naming convention as used by Nesterovsky...
« Last Edit: August 21, 2012, 06:28:48 PM by Lee Mac »

BlackBox

  • King Gator
  • Posts: 3770
Re: List Sub-Directories within a Directory
« Reply #28 on: August 21, 2012, 06:36:53 PM »
On the topic of accreditation....

First, those who know me, know full well that I too share the belief in giving credit where credit is due... I'd like to think of myself as being adept at coding, but despite my personal aptitude, I wouldn't be where I am without the help of others, many of whom are now participating in this thread.

Accreditation seems to be, in my limited experience, much more intense for LISP code than with .NET development, unless publicly posted by some of the top 'personalities' so-to-speak.

For example, as I learn more and more about Inheritance in .NET development, one does not appear to need to be the same level of attributing this developer or that, when creating a LispException Class, or its derivatives as shown here.

... I don't know who to properly accredit the System.Exception Class, so I simply thank (and attribute) Gile instead for showing me how to create dependent *Exception Classes from the base (and include a link to that thread for reference).

Especially given the many years between them, and that yours (Gile) was also posted on a French forum, I'm inclined to believe that Lee was able to develop those function through his own learning experience... Just my humble opinion.

Respectfully,

~RM
"How we think determines what we do, and what we do determines what we get."

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: List Sub-Directories within a Directory
« Reply #29 on: August 21, 2012, 06:52:54 PM »
Quote
I'm not sure what you mean by the 'obsolete French math symbols'

Extract from Wikipedia (fr)
Quote
En France, le produit vectoriel de u et de v est noté u∧v, où le symbole ∧ se lit wedge ou vectoriel. Cette notation a été initiée par Cesare Burali-Forti et Roberto Marcolongo en 1908. [...]
Dans la littérature anglophone (et au Canada francophone, ainsi qu'en Suisse), le produit vectoriel est noté u×v. Cette notation est due à Josiah Willard Gibbs.
Google translation:
Quote
In France, the vector product of u and v is denoted u ∧ v, where the symbol ∧ reads wedge or vector. This rating was initiated by Cesare Burali-Forti and Roberto Marcolongo in 1908 . [...]
In the English literature (and in French Canada, and Switzerland), the vector product u × v is noted. This notation is due to Josiah Willard Gibbs.

Long time ago, at school I learned the first notation that's the reason why I called my cross product v^v. In France this notation tend to disapear these days and more and more use the u X v "English" notation now.

I think that if I had an English culture (or if i was younger) I'd choose vxv for the cross product and something like v*v for the dot product.

Anyway, there's nothing against you, as I said I consider were are all "hackers" and I don't remember I ever "signed" these little routines I published many times here and elsewhere, so I do not reclaim any credit for that.
« Last Edit: August 21, 2012, 06:56:36 PM by gile »
Speaking English as a French Frog