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

0 Members and 1 Guest are viewing this topic.

deegeecees

  • Guest
List Sub-Directories within a Directory
« on: August 20, 2012, 02:23:10 PM »
Been quite a while since I've hacked away in Lisp, but I'm looking for a way to list the sub-directories in a given directory. Fairly easy and straight forward. I've looked at the vl- functions but nothing seems to jump out at me. Could someone point me in the right direction?

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: List Sub-Directories within a Directory
« Reply #1 on: August 20, 2012, 02:31:27 PM »
Hi,

IMO, Vanilla LISP (DXF) is a better way with dictionaries.

Here's a little routine which returns an assoc list of all entries of the specified dictionary. Each pair is of type (key . ename).
Warning, Dictionariy entries may be either dictionaries or xrecords or custom objects.

Code - Auto/Visual Lisp: [Select]
  1. (defun gc:GetDictEntries (dict / result)
  2.   (and (= (type dict) 'ENAME) (setq dict (entget dict)))
  3.   (while
  4.     (setq dict (vl-member-if (function (lambda (x) (= (car x) 3))) (cdr dict)))
  5.      (setq result (cons (cons (cdar dict) (cdadr dict)) result))
  6.   )
  7.   (reverse result)
  8. )
Speaking English as a French Frog

BlackBox

  • King Gator
  • Posts: 3770
Re: List Sub-Directories within a Directory
« Reply #2 on: August 20, 2012, 02:37:14 PM »
You could use Scripting.FileSystemObject Object:

Code - Auto/Visual Lisp: [Select]
  1. (defun _GetSubFolders (oFolder / oSubs)
  2.   (if (< 0
  3.             (vlax-get
  4.               (setq oSubs (vlax-get oFolder 'subfolders))
  5.               'count
  6.             )
  7.          )
  8.     (vlax-for x oSubs
  9.       (setq subFolders (cons (vlax-get x 'path) subFolders))
  10.       (_GetSubFolders x)
  11.     )
  12.   )
  13. )
« Last Edit: August 20, 2012, 03:40:38 PM by RenderMan »
"How we think determines what we do, and what we do determines what we get."

BlackBox

  • King Gator
  • Posts: 3770
Re: List Sub-Directories within a Directory
« Reply #3 on: August 20, 2012, 02:58:35 PM »
Quick example:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:FOO (/ *error* _GetSubFolders acApp oShell oShellFolder path
  2.               oFso oFolder subFolders
  3.              )
  4.  
  5.   (defun *error* (msg)
  6.     (if oShell
  7.       (vlax-release-object oShell)
  8.     )
  9.     (if oFso
  10.       (vlax-release-object oFso)
  11.     )
  12.     (cond ((not msg))                                                   ; Normal exit
  13.           ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
  14.           ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
  15.     )
  16.     (princ)
  17.   )
  18.  
  19.   (defun _GetSubFolders (oFolder / oSubs)
  20.     (if (< 0
  21.            (vlax-get
  22.              (setq oSubs (vlax-get oFolder 'subfolders))
  23.              'count
  24.            )
  25.         )
  26.       (vlax-for x oSubs
  27.         (setq subFolders (cons (vlax-get x 'path) subFolders))
  28.         (_GetSubFolders x)
  29.       )
  30.     )
  31.   )
  32.  
  33.            (setq oShell (vla-getinterfaceobject acApp "Shell.Application"))
  34.            (setq oShellFolder
  35.                   (vlax-invoke
  36.                     oShell
  37.                     'BrowseForFolder
  38.                     (vla-get-hwnd acApp)
  39.                     "Select a folder to add to SFSP:"
  40.                     0
  41.                     17
  42.                   )
  43.            )
  44.            (setq path (vlax-get-property
  45.                         (vlax-get-property oShellFolder 'Self)
  46.                         'Path
  47.                       )
  48.            )
  49.            (setq oFso
  50.                   (vla-getinterfaceobject acApp "Scripting.FileSystemObject")
  51.            )
  52.            (setq oFolder (vlax-invoke oFso 'getfolder path))
  53.            (not (_GetSubFolders oFolder))
  54.            subFolders
  55.       )
  56.     (progn
  57.       (prompt "\nSub-Folders found: \n")
  58.       (foreach sub subFolders
  59.         (prompt (strcat "\n\t\t" sub))
  60.       )
  61.       (terpri)
  62.       (*error* nil)
  63.     )
  64.     (cond (oFolder (*error* "No subfolders found"))
  65.           (oFso (*error* "Unable to obtain Folder Object"))
  66.           (path
  67.            (*error*
  68.              "Unable to create \"Scripting.FileSystemObject\" Object"
  69.            )
  70.           )
  71.           (oShellFolder (*error* "Unable to obtain path property"))
  72.           (oShell (*error* "No directory selected"))
  73.           (acApp
  74.            (*error* "Unable to create \"Shell.Application\" Object")
  75.           )
  76.     )
  77.   )
  78. )
"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 #4 on: August 20, 2012, 03:27:29 PM »
Oopss !! I confused Directory and dictionary  :ugly:

Look at the vl-directory-files function with -1 flag.
Speaking English as a French Frog

chlh_jd

  • Guest
Re: List Sub-Directories within a Directory
« Reply #5 on: August 20, 2012, 03:36:12 PM »
following's code written by xyp-1964
Code: [Select]
(defun xyp-GetFolders (path SubFolders-TNil / main sub folder)
  (defun main (path / folders)
    (if (member "." (setq folders (vl-directory-files path nil -1)))
      (cddr folders)
      folders
    )
  )
  (defun sub (path)
    (mapcar (function (lambda (folder / temp)
       (cons (setq temp (strcat path "/" folder))
     (apply 'append (sub temp))
       )
     ))
    (main path)
    )
  )
  (if (setq lst
     (if SubFolders-TNil
       (apply (function append) (sub path))
       (if (setq folders (main path))
(mapcar (function (lambda (x) (strcat path "/" x))) folders)
       )
     )
      )
    (vl-sort (mapcar (function strcase) lst) (function <))
  )
)

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: List Sub-Directories within a Directory
« Reply #6 on: August 21, 2012, 04:22:53 AM »
Here's my version (also using vl-directory-files):
Code - Auto/Visual Lisp: [Select]
  1. (defun _GetSubfolders (path / )
  2.   (setq path (vl-string-right-trim "\\/" path))
  3.   (mapcar '(lambda (name) (strcat path "\\" name))
  4.           (vl-remove-if '(lambda (name) (wcmatch name "`.,`.`."))
  5.             (vl-directory-files path nil -1))))
  6.  
  7. (defun _GetRecursiveSubfolders (path /)
  8.   (setq path (vl-string-right-trim "\\/" path))
  9.          (mapcar '(lambda (name / temp)
  10.                     (if (setq temp (_GetRecursiveSubfolders (setq name (strcat path "\\" name))))
  11.                       (cons name temp)
  12.                       (list name)))
  13.                  (vl-remove-if '(lambda (name) (wcmatch name "`.,`.`."))
  14.                    (vl-directory-files path nil -1)))))
Just take note that if your folders contain Unicode characters this won't list them. If you use unicode characters in your foldernames, then RenderMan's solution of using the Scripting.FileSystemObject is the only one I know of which works well.

Edit: Slightly simplified recursive subfolder list:
Code - Auto/Visual Lisp: [Select]
  1. (defun _GetRecursiveSubfolders (path /)
  2.   (setq path (vl-string-right-trim "\\/" path))
  3.          (mapcar '(lambda (name / temp)
  4.                     (cons name (_GetRecursiveSubfolders (setq name (strcat path "\\" name)))))
  5.                  (vl-remove-if '(lambda (name) (wcmatch name "`.,`.`."))
  6.                    (vl-directory-files path nil -1)))))
I don't seem to be able to get at a tail-call-recursive method for this though. So if your paths are around 20000 deep expect errors ... though you'd have some strange folder structure to get to that point  :ugly:
« Last Edit: August 21, 2012, 04:33:37 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: List Sub-Directories within a Directory
« Reply #7 on: August 21, 2012, 04:58:07 AM »
And my version using the FileSystemObject:
Code - Auto/Visual Lisp: [Select]
  1. (defun _GetSubfolders  (path recurse / fso folders)
  2.              (setq fso (vl-catch-all-apply 'vlax-get-or-create-object '("Scripting.FileSystemObject")))))
  3.     (setq folders (apply 'append
  4.                          (mapcar '(lambda (f / p)
  5.                                     (cons (setq p (vlax-get f 'Path))
  6.                                           (if recurse (_GetSubfolders p recurse))))
  7.                                  (cond ((and (not (vl-catch-all-error-p (setq path (vl-catch-all-apply 'vlax-invoke (list fso 'GetFolder path)))))
  8.                                              (not (vl-catch-all-error-p (setq folders (vl-catch-all-apply 'vlax-get (list path 'SubFolders))))))
  9.                                         (Collection->List folders)))))))
  10.   (vl-catch-all-apply 'vlax-release-object (list fso))
  11.   folders)
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

gile

  • Gator
  • Posts: 2507
  • Marseille, France
Re: List Sub-Directories within a Directory
« Reply #8 on: August 21, 2012, 05:38:36 AM »
Hi,

Quote
I don't seem to be able to get at a tail-call-recursive method for this though.
AFAIK, AutoLISP doesn't manage tail-recursion.
Speaking English as a French Frog

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: List Sub-Directories within a Directory
« Reply #9 on: August 21, 2012, 06:22:09 AM »
Yes, I know - though it's still a good principle to try for. Otherwise all recursive functions would run into stack overflows if the list of calls are long (even if the interpreter/compiler optimizes tail-recursion).

Anyhow, it's a moot point for this scenario. I think the PC might just crash if you have folder paths 20000 levels deep!

One other thing to take note of: The recursive folder listing might take some time if there are 100's (or even 1000's) of folders - never mind their depth. A possible solution is to use dgorsman's depth-limit, see my version of this here.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: List Sub-Directories within a Directory
« Reply #10 on: August 21, 2012, 06:33:09 AM »
Perhaps as an iterative version:

Code - Auto/Visual Lisp: [Select]
  1. (defun _getsubfolders ( dir / lst out sub )
  2.     (setq lst (list dir))
  3.     (while lst
  4.         (setq sub nil)
  5.         (foreach dir lst
  6.             (setq sub
  7.                 (append sub
  8.                     (mapcar (function (lambda ( x ) (strcat dir "\\" x)))
  9.                         (vl-remove-if
  10.                             (function (lambda ( x ) (member x '("." ".."))))
  11.                             (vl-directory-files dir nil -1)
  12.                         )
  13.                     )
  14.                 )
  15.             )
  16.         )
  17.         (setq out (append sub out)
  18.               lst sub
  19.         )
  20.     )
  21.     out
  22. )

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: List Sub-Directories within a Directory
« Reply #11 on: August 21, 2012, 06:38:31 AM »
Yes, I was thinking in the same lines. But seeing as the recursive error only happens so far along (http://www.cadtutor.net/forum/showthread.php?62502-Help-Limit-of-recursive&s=f9ecbd9f8180770b9dac40e615ddf486) I don't think it would ever apply in this case.

Anyhow, folder pathing simply lends itself to recursion doesn't it? It's basically a tree structure, which is one of the major uses of recursion. Though as you've shown you don't "need" recursion for such - just some state variables.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: List Sub-Directories within a Directory
« Reply #12 on: August 21, 2012, 06:57:24 AM »
Just skinning the cat  8-)

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: List Sub-Directories within a Directory
« Reply #13 on: August 21, 2012, 06:57:45 AM »

deegeecees

  • Guest
Re: List Sub-Directories within a Directory
« Reply #14 on: August 21, 2012, 09:04:00 AM »
Oopss !! I confused Directory and dictionary  :ugly:

Look at the vl-directory-files function with -1 flag.

Thats the one, thank you!

I appreciate all the help, and replies. Some interesting concepts.

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: 309
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: 12906
  • 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: 12906
  • 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: 12906
  • 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: 12906
  • 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

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: List Sub-Directories within a Directory
« Reply #30 on: August 21, 2012, 07:14:38 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.

That's interesting -

As part of my Mathematics degree I studied vector calculus in which the wedge product (i.e. v^v) was used exclusively throughout the course as the notation to imply the higher-dimensional generalisation of the familiar 'cross product'. We also studied the generalisation of the dot-product (called the inner-product) over a vector-space, which uses this alternative notation.

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.

I agree, for ubiquitous functions such as these, I also have no intention to claim copyright, but simply included my name as I wrote them at the time of posting them on my site.

PKENEWELL

  • Bull Frog
  • Posts: 309
Re: List Sub-Directories within a Directory
« Reply #31 on: August 22, 2012, 04:33:15 PM »
Lee,

You are absolutely correct and I give you my sincere apologies. In my defence I have not intented to take credit for your code, nor am I using it for ill gains - not even in my own workplace. It is my fault however that I did not retain the credit for your code in my utilities. I simply reformated the function names and headers to keep them organized in my personal utilities. It was a more major mistake on my part as well to share it on this site without giving you your due credit. From now on: If the code is not originally mine - I will in the least part keep the credit where it is due in the header of the code. In fact - I will not even post code from my personal utilities if I did not originally author it. I will edit my earlier post and add credit for your excellent work. So - I throw myself at the mercy of the court. My ignorance will not be repeated!
"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

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: List Sub-Directories within a Directory
« Reply #32 on: August 22, 2012, 04:40:50 PM »
I must confess I did not review the code line for line as I'm swamped.
Eye see what you did there.   :wink:
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

chlh_jd

  • Guest
Re: List Sub-Directories within a Directory
« Reply #33 on: August 22, 2012, 04:55:44 PM »
I must confess I did not review the code line for line as I'm swamped.
Eye see what you did there.   :wink:
1+

some time before I came into Theswamp , I've got this same mistake . because I copy from a website which not notice the author and where it come from .
and then someone tell me , I put the author name in it , Now I think everyone very friendly to me  :-)

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: List Sub-Directories within a Directory
« Reply #34 on: August 23, 2012, 05:31:30 AM »
You are absolutely correct and I give you my sincere apologies. In my defence I have not intented to take credit for your code, nor am I using it for ill gains - not even in my own workplace. It is my fault however that I did not retain the credit for your code in my utilities. I simply reformated the function names and headers to keep them organized in my personal utilities. It was a more major mistake on my part as well to share it on this site without giving you your due credit. From now on: If the code is not originally mine - I will in the least part keep the credit where it is due in the header of the code. In fact - I will not even post code from my personal utilities if I did not originally author it. I will edit my earlier post and add credit for your excellent work. So - I throw myself at the mercy of the court. My ignorance will not be repeated!

I accept your apology and am prepared to give you the benefit of the doubt with regards to your intentions for the code, though I would ask that you familiarise yourself with the Terms of Use applicable to all code pubished on my site.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: List Sub-Directories within a Directory
« Reply #35 on: August 23, 2012, 06:02:43 AM »
< .. > 
So - I throw myself at the mercy of the court.


For mine, benefit of the doubt :- deduct 2 points.
... but you get full points for posting, attempting to solve the issue.


Something that gets forgotten sometimes :
We all stand on the shoulders of giants.

Regards
and welcome to theSwamp.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: List Sub-Directories within a Directory
« Reply #36 on: August 23, 2012, 06:13:01 AM »
...
We all stand on the shoulders of giants.
...

ourselves become giants...  8-)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: List Sub-Directories within a Directory
« Reply #37 on: August 23, 2012, 06:18:25 AM »
...
We all stand on the shoulders of giants.
...

ourselves become giants...  8-)

8-) yes.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: List Sub-Directories within a Directory
« Reply #38 on: August 23, 2012, 06:31:38 AM »
...
We all stand on the shoulders of giants.
...
All too true. I don't think I could've written anything meaningful without seeing some examples from "Giants". I've even got some tips from yourself in the past (and many others including Lee). I try to give credit, but the issue is where does it stop. Where does the code become yours and where is it still just a modification you did to someone else's code?

I think this case shows a clear extreme where the code is an exact copy. And IMO no matter what license there was involved - a clear statement of such is the very minimum that should be done. And especially as Lee's licensing clearly states do's and dont's this is a no-brainer.

But then there's the other extreme: Where you use a concept from another's code inside something different. E.g. I've made an optimized version of LastN - by using a concept I saw in some code you posted. I did include a link to your code, but perhaps that might be going a bit far to accredit you - the 2 functions do something different. I just felt I wanted to credit you with giving me the idea. But if I go further from that there is probably very few single pieces of code I've ever written (at least non-trivial) which I didn't learn from someone else's example - thus most pieces / lines might then have a comment stating where I've first encountered such.

ourselves become giants...  8)
Well ... we hope so!  :kewl: IMO you have!
« Last Edit: August 23, 2012, 06:35:31 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

VovKa

  • Water Moccasin
  • Posts: 1626
  • Ukraine
Re: List Sub-Directories within a Directory
« Reply #39 on: August 23, 2012, 06:44:41 AM »
whoever finds my code wherever over the internet, fell free to steal/borrow/use/modify, i don't care

PKENEWELL

  • Bull Frog
  • Posts: 309
Re: List Sub-Directories within a Directory
« Reply #40 on: August 23, 2012, 11:53:44 AM »
Lee,

Thank you for accepting my apologies. Bottom Line is: I Should've know better. I have been coding in AutoLISP since 1994. I admit I have become very rusty however since I do not use AutoCAD as my primary CAD system anymore - having switched to Autodesk Inventor several years ago. I simply enjoy playing around with new code in my spare time. I will read your terms of use, and you will NOT see a repeat of that mistake again.  :ugly:

- Phil Kenewell
"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: 12906
  • London, England
Re: List Sub-Directories within a Directory
« Reply #41 on: August 23, 2012, 12:09:54 PM »
No problem Phil, thank you for your understanding.