Author Topic: Search path...  (Read 12629 times)

0 Members and 1 Guest are viewing this topic.

MeasureUp

  • Bull Frog
  • Posts: 462
Search path...
« on: July 23, 2013, 01:20:37 AM »
I know that a specified file is existing and I want to find its location.
How do I get the path of the document (txt, doc... etc.)?
Thanks in advance.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Search path...
« Reply #1 on: July 23, 2013, 02:33:48 AM »
I've used this successfully for a while ..

Code - Auto/Visual Lisp: [Select]
  1. ;;(findFileFromRoot "D:\\"  "FileName.ext")
  2. ;;(findFileFromRoot "D:\\folder\\"  "FileName.ext")
  3. (defun findFileFromRoot (root file)
  4.   (setq root (vl-string-right-trim "\\"
  5.                                    (vl-string-translate "/" "\\" root)
  6.              )
  7.   )
  8.   (cond ((findfile (strcat root "\\" file)))
  9.         ((vl-some '(lambda (fn)
  10.                      (if (wcmatch fn "`.,`.`.")
  11.                        nil
  12.                        (findfilefromroot (strcat root "\\" fn) file)
  13.                      )
  14.                    )
  15.                   (vl-directory-files root nil -1)
  16.          )
  17.         )
  18.   )
  19. )

Code - Auto/Visual Lisp: [Select]
  1. (findFileFromRoot "K:\\SteelTools\\"  "KDUB_3DPlate.lsp")

Quote from:  RETURNS
"K:\\SteelTools\\SOURCE_19\\MISC TOOLS\\KDUB_3DPlate.lsp"
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.

MeasureUp

  • Bull Frog
  • Posts: 462
Re: Search path...
« Reply #2 on: July 23, 2013, 03:00:02 AM »
I've used this successfully for a while ..

Code - Auto/Visual Lisp: [Select]
  1. ;;(findFileFromRoot "D:\\"  "FileName.ext")
  2. ;;(findFileFromRoot "D:\\folder\\"  "FileName.ext")
  3. (defun findFileFromRoot (root file)
  4.   (setq root (vl-string-right-trim "\\"
  5.                                    (vl-string-translate "/" "\\" root)
  6.              )
  7.   )
  8.   (cond ((findfile (strcat root "\\" file)))
  9.         ((vl-some '(lambda (fn)
  10.                      (if (wcmatch fn "`.,`.`.")
  11.                        nil
  12.                        (findfilefromroot (strcat root "\\" fn) file)
  13.                      )
  14.                    )
  15.                   (vl-directory-files root nil -1)
  16.          )
  17.         )
  18.   )
  19. )

Code - Auto/Visual Lisp: [Select]
  1. (findFileFromRoot "K:\\SteelTools\\"  "KDUB_3DPlate.lsp")

Quote from:  RETURNS
"K:\\SteelTools\\SOURCE_19\\MISC TOOLS\\KDUB_3DPlate.lsp"
Thanks so much, Kerry.
I will try it out tomorrow.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Search path...
« Reply #3 on: July 23, 2013, 03:39:34 AM »
Just be warned that searching through lots of sub-folders could take some time. Even worse if searching on a network / remote folder. Here's a thread which does some testing of various searching methods:
http://forums.augi.com/showthread.php?132773-Search-file-in-a-specific-drive&p=1141241&viewfull=1#post1141241
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Search path...
« Reply #4 on: July 23, 2013, 08:23:52 AM »
I've used this successfully for a while ..

Code - Auto/Visual Lisp: [Select]
  1. ;;(findFileFromRoot "D:\\"  "FileName.ext")
  2. ;;(findFileFromRoot "D:\\folder\\"  "FileName.ext")
  3. (defun findFileFromRoot (root file)
  4.   (setq root (vl-string-right-trim "\\"
  5.                                    (vl-string-translate "/" "\\" root)
  6.              )
  7.   )
  8.   (cond ((findfile (strcat root "\\" file)))
  9.         ((vl-some '(lambda (fn)
  10.                      (if (wcmatch fn "`.,`.`.")
  11.                        nil
  12.                        (findfilefromroot (strcat root "\\" fn) file)
  13.                      )
  14.                    )
  15.                   (vl-directory-files root nil -1)
  16.          )
  17.         )
  18.   )
  19. )

Looks familiar...  :roll: :(

« Last Edit: July 23, 2013, 08:35:11 AM by Lee Mac »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Search path...
« Reply #5 on: July 23, 2013, 08:36:50 AM »
< .. >

Looks familiar...  :roll: :-(

Lee, I've been writing code from the time you were in nappies.
There are a couple of pieces of code in the world that you didn't write (or re-write) you know, so don't roll your bloody eyes at me.
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.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Search path...
« Reply #6 on: July 23, 2013, 09:34:02 AM »
< .. >

Looks familiar...  :roll: :-(

Lee, I've been writing code from the time you were in nappies.
There are a couple of pieces of code in the world that you didn't write (or re-write) you know, so don't roll your bloody eyes at me.

I couldn't care less how long you've been writing code for - that's no excuse for plagiarism.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Search path...
« Reply #7 on: July 23, 2013, 09:37:43 AM »
I loath taking sides, I like both you gentlemen, but I do not believe for a nano second that Kerry has plagiarized anyone's code and an apology is due.
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: Search path...
« Reply #8 on: July 23, 2013, 10:06:04 AM »
You expect me to believe that carbon copy of my code was written independently?

owenwengerd

  • Bull Frog
  • Posts: 451
Re: Search path...
« Reply #9 on: July 23, 2013, 10:51:21 AM »
It's possible for anybody to unwittingly copy code they saw previously without even realizing it. Sometimes it's impossible to determine which is the original and which is the copy. Plagiarism should be called out when it's found, but Lee I think you should explain the discrepancy between the code on your web site and the (apparently more recent) code in your post before leveling plagiarism charges.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Search path...
« Reply #10 on: July 23, 2013, 10:55:35 AM »
Be careful Lee -- it's a double edged sword you're wielding -- Kerry is a well respected author, one who has advocated, and demonstrated proper attribution for decades -- how do we know you didn't "roll yer own" based upon his original work and then forgot where you got the inspiration?

As stated, I like you both, respect both of your collective works and significant contribution to the knowledge pool, but unless you can prove the plagiarism assertion it remains a really unfortunate gaffe.
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: Search path...
« Reply #11 on: July 23, 2013, 11:09:27 AM »
I think you should explain the discrepancy between the code on your web site and the (apparently more recent) code in your post before leveling plagiarism charges.

I simply updated the code as published on my site when posting in the thread to which I have referred - you will see the distinct similarities between the code as found on my site and the updated version.

how do we know you didn't "roll yer own" based upon his original work and then forgot where you got the inspiration?

Since Kerry's post above of the 'findfilefromroot' function appears to be the only occurrence of the function not only here at the Swamp, but across the entire web, I think its evident who has copied from who.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Search path...
« Reply #12 on: July 23, 2013, 11:17:06 AM »
Sorry, not evident to me. This is an ugly thread. I'm out.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

owenwengerd

  • Bull Frog
  • Posts: 451
Re: Search path...
« Reply #13 on: July 23, 2013, 11:33:10 AM »
I simply updated the code as published on my site when posting in the thread to which I have referred...

One might infer that you updated your code after seeing Kerry's more efficient version.

For such a simple function, identical variable names and code are not sufficient in and of themselves to prove infringement. It comes down not to similarity, but who created it first, and did the second person have access to the first or did both arrive at the same implementation independently. You published in February and you can prove it. I expect Kerry to either provide evidence that his came earlier, or concede that he copied your code.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Search path...
« Reply #14 on: July 23, 2013, 01:05:35 PM »
One might infer that you updated your code after seeing Kerry's more efficient version.

I fully appreciate that point, however as I've noted, this is the first appearance of Kerry's function not only on this forum, but on the entire web as far as I can tell, and so I can assure you that this is the first I have seen of it.