Home > Community > Forums > PCB SKILL > Search files inside sub directories

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 Search files inside sub directories 

Last post Wed, May 9 2012 4:39 PM by eDave. 3 replies.
Started by pcbnagaraj 07 May 2012 03:36 AM. Topic has 3 replies and 1891 views
Page 1 of 1 (4 items)
Sort Posts:
  • Mon, May 7 2012 3:36 AM

    • pcbnagaraj
    • Top 150 Contributor
    • Joined on Tue, Dec 6 2011
    • bangalore, Karnataka
    • Posts 55
    • Points 1,130
    Search files inside sub directories Reply
    Dear All,

    Is there a way to search all *.dra files in the sub directories?

    The below will list the dra in the root path but I need to get all dra files in the sub directories as well.

    dra_list =  setof(file, getDirFiles(dra_path), cadddr(axlDMFileParts(file)) == "dra")

    any suggestion is appreciated

    Thanks,

    Nagaraj.
    • Post Points: 5
  • Tue, May 8 2012 4:37 AM

    • pcbnagaraj
    • Top 150 Contributor
    • Joined on Tue, Dec 6 2011
    • bangalore, Karnataka
    • Posts 55
    • Points 1,130
    RE: Search files inside sub directories Reply
    Any suggestion??

    Thanks,

    Nagaraj.
    • Post Points: 20
  • Tue, May 8 2012 8:05 AM

    • Randy R
    • Top 50 Contributor
    • Joined on Wed, Jul 16 2008
    • Dupont, WA
    • Posts 192
    • Points 3,025
    Re: RE: Search files inside sub directories Reply

    You could have the Operating System create a list of filenames in a file then read that file.

    For a Windows system:  system("dir *.brd /b/s >dir_list.txt")

    Hope this helps.

    Good Day, R².
    • Post Points: 20
  • Wed, May 9 2012 4:39 PM

    • eDave
    • Top 10 Contributor
    • Joined on Sun, Jul 13 2008
    • Christchurch, 00-NZ
    • Posts 707
    • Points 15,395
    Re: RE: Search files inside sub directories Reply
    defun( DE_GetSubDirFiles (dir, fileNameOrTypeOnly @optional keepFileListing, "ttg")
     let((fileName, fileType, listingFile, p, ln, filePath, files)
    rexCompile("/")
    dir = rexReplace(dir, "\\\\", 0)
    fileName = if(index(fileNameOrTypeOnly, ".") then fileNameOrTypeOnly else strcat("*.", fileNameOrTypeOnly))
    fileType = lastelem(parseString(fileName, "."))
    sprintf(listingFile, "%s\\%s_files.listing", getShellEnvVar("TEMP"), fileType)
    when(zerop(system(sprintf(nil, "dir %s\\%s /s/b/-d > %s", dir, fileName, listingFile)))
    p = infile(listingFile)
    while(gets(ln, p)
    filePath = substring(ln, 1, strlen(ln) - 1)
    when(lastelem(parseString(filePath, ".")) == fileType, files = cons(axlOSSlash(filePath), files))
    )
    close(p)
    )
    and(!keepFileListing, isFile(listingFile), deleteFile(listingFile))
    files
    ))
    ; draFiles = DE_GetSubDirFiles("L:/library/build/development/allegro/symbols/package", "dra")
    Dave Elder, Tait Communications
    • Post Points: 5
Page 1 of 1 (4 items)
Sort Posts:
Started by pcbnagaraj at 07 May 2012 03:36 AM. Topic has 3 replies.