Author Topic: Could findfile search in all PC?  (Read 2336 times)

0 Members and 1 Guest are viewing this topic.

HasanCAD

  • Swamp Rat
  • Posts: 1422
Could findfile search in all PC?
« on: February 25, 2013, 09:00:56 AM »
Could findfile search in all PC not support folder only?
OR there is another way for that?

ribarm

  • Gator
  • Posts: 3296
  • Marko Ribar, architect
Re: Could findfile search in all PC?
« Reply #1 on: February 25, 2013, 09:19:59 AM »
If you know the path where to search for file and you supply it to the function, then it will find if file exist...

You may also want to look into getfield function, as it has options for searching for files when dialog box is active...
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1454
  • Marco
Re: Could findfile search in all PC?
« Reply #2 on: February 25, 2013, 09:28:30 AM »
Code: [Select]
; Marc'Antonio Alessi, Italy - http://alessi.xoom.it//alessi/
;
; Function: ALE_UtlFilesGetFolders
;
; Version 1.00 - 09/06/2006
;
; Description:
;   Returns a list of subdirectories found in the specified directory,
;   the return values contain trailing double-backslashes (\\)
;   if RecFlg = T > scan the entire structure
;
; Arguments:
;   In_Pat = A string containing an existing path
;            do not need trailing double-backslashes
;            if nil or "" uses the current directory.

;   RecFlg = flag > T   = scan the entire structure
;                 > nil = do not scan
;
; Examples:
;   (ALE_UtlFilesGetFolders "C:\\Temp" nil)
;   (ALE_UtlFilesGetFolders "C:\\Temp\\" T)
;
; Return Values:
;   [LIST] A list of subdirectories if successful.
;
(defun ALE_UtlFilesGetFolders (In_Pat RecFlg / FilNam OutLst)
  (or
    (wcmatch In_Pat "*[\\/]")
    (setq In_Pat (strcat In_Pat "\\"))
  )
  (if RecFlg
    (ALE_UtlFilesGetFolders_Aux In_Pat)
    (foreach ForElm (cddr (vl-directory-files In_Pat nil -1))
      (setq OutLst (cons (strcat In_Pat ForElm "\\") OutLst))
    )
  )
  (reverse OutLst)
)
;
; Function: ALE_UtlFilesGetFolders_Aux
; Auxiliary function for: ALE_UtlFilesGetFolders
;
(defun ALE_UtlFilesGetFolders_Aux (In_Pat)
  (foreach ForElm (cddr (vl-directory-files In_Pat nil -1))
    (setq
      FilNam (strcat In_Pat ForElm "\\")
      OutLst (cons FilNam OutLst)
    )
    (ALE_UtlFilesGetFolders_Aux FilNam)
  )
)
;
; Function: ALE_UtlFilesGetFiles
;
; Version 1.01 - 09/06/2006
;
; Description:
;   Returns a list of files found in the specified directory,
;   if RecFlg = T > scan the entire structure
;
; Arguments:
;   In_Pat = A string containing an existing path
;            do not need trailing double-backslashes
;
;   FlsSpc = The desired file or files, can contain wildcard characters
;            ("*" and "?"),  all files > *.*

;   RecFlg = flag > T   = scan the entire structure
;                 > nil = do not scan
;
; Examples:
;   (ALE_UtlFilesGetFiles "C:\\Temp\\" "*.dwg" nil)
;   (ALE_UtlFilesGetFiles "C:\\Temp\\" "*.dwg"   T)
;
; Return Values:
;   [LIST] A list of files if successful
;
(defun ALE_UtlFilesGetFiles (In_Pat FlsSpc RecFlg / OutLst)
  (or
    (wcmatch In_Pat "*[\\/]")
    (setq In_Pat (strcat In_Pat "\\"))
  )
  (foreach ForElm (vl-directory-files In_Pat FlsSpc 1)
    (setq OutLst (cons (strcat In_Pat ForElm) OutLst))
  )
  (if RecFlg
    (foreach ForElm (ALE_UtlFilesGetFolders In_Pat RecFlg)
      (foreach ForEl2 (vl-directory-files ForElm FlsSpc 1)
        (setq OutLst (cons (strcat ForElm ForEl2) OutLst))
      )
    )
  )
  (reverse OutLst)
)

Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: Could findfile search in all PC?
« Reply #3 on: February 25, 2013, 09:28:44 AM »

Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: Could findfile search in all PC?
« Reply #4 on: February 25, 2013, 09:47:31 AM »
Also: http://lee-mac.com/findfile.html

Here is an updated version:

Code - Auto/Visual Lisp: [Select]
  1. ;; Findfile  -  Lee Mac
  2. ;; Recursively searches the root directory and all subfolders for the supplied file
  3.  
  4. (defun LM:findfile ( root file )
  5.     (setq root (vl-string-right-trim "\\" (vl-string-translate "/" "\\" root)))
  6.     (cond
  7.         (   (findfile (strcat root "\\" file)))
  8.         (   (vl-some
  9.                '(lambda ( f ) (if (wcmatch f "`.,`.`.") nil (LM:findfile (strcat root "\\" f) file)))
  10.                 (vl-directory-files root nil -1)
  11.             )
  12.         )
  13.     )
  14. )
« Last Edit: February 25, 2013, 09:51:45 AM by Lee Mac »

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Could findfile search in all PC?
« Reply #5 on: February 26, 2013, 12:33:39 AM »
Thanks all
working perfectly

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: Could findfile search in all PC?
« Reply #6 on: February 26, 2013, 06:35:33 AM »
Very cool!

Also: http://lee-mac.com/findfile.html

Here is an updated version:

Code - Auto/Visual Lisp: [Select]
  1. ;; Findfile  -  Lee Mac
  2. ;; Recursively searches the root directory and all subfolders for the supplied file
  3.  
  4. (defun LM:findfile ( root file )
  5.     (setq root (vl-string-right-trim "\\" (vl-string-translate "/" "\\" root)))
  6.     (cond
  7.         (   (findfile (strcat root "\\" file)))
  8.         (   (vl-some
  9.                '(lambda ( f ) (if (wcmatch f "`.,`.`.") nil (LM:findfile (strcat root "\\" f) file)))
  10.                 (vl-directory-files root nil -1)
  11.             )
  12.         )
  13.     )
  14. )

Lee Mac

  • Seagull
  • Posts: 12921
  • London, England
Re: Could findfile search in all PC?
« Reply #7 on: February 26, 2013, 07:21:22 AM »

HasanCAD

  • Swamp Rat
  • Posts: 1422
Re: Could findfile search in all PC?
« Reply #8 on: February 26, 2013, 07:45:23 AM »
...
Here is an updated version:
...

More than expected