LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Search for pattern in sub directories

Hi,
What I am trying to do is search through a folder subdirectory to return files matching a certain pattern.  I know how to search inside one folder, but I want to be able to do the following:
 
1. User chooses folder to search
2. Inside that folder is multiple folders
3. Inside these multiple folders are the files matching the pattern
 
Would it be possible to search the User defined folder for more folders, then search these folders for the files matching the pattern?
 
Thanks,
Adam
 
 
0 Kudos
Message 1 of 14
(4,816 Views)
Hi Adam

In the OpenG libraries (file library) there's a recursive directory listing VI.
You can download the libraries using VI package manager.

Regards, Daniel

Message 2 of 14
(4,798 Views)

There is a vi in LabVIEW 8.2,  on the functions pallete > file io > advanced file functions > Recursive File List.vi

This vi will show you all the file and sub folders within the main folder, you can then search those folders.

Brian
Message 3 of 14
(4,798 Views)
Thanks for the fast reply, I have LV 8 so I will have to use the VI Package Manager.
 
Thanks again,
Adam
0 Kudos
Message 4 of 14
(4,788 Views)

FYI

In 8.0, the List Folder function (located in the same place as the Recursive File List.vi in 8.2) will return both file names and folder names as strings. 

Brian
Message 5 of 14
(4,782 Views)
This thread details a vi for recursive file list that has been available since 7.0.
Message 6 of 14
(4,765 Views)
Hi,
I found the Recursive file list vi.  I have my program somewhat working.  I was able to search through the main folder to find all of the sub folder.  Here is where I get stuck.  I am trying to perform a search on these folders to display all of the files inside those folders.  Ok, that sounds confusing.  Heres is a list of what I am doing:
 
1.  Search main folder for sub folder.    <- Works fine
2.  Search the sub folders for files.  <- dosen't work
 
I guess I am getting stuck on indexing the array.  The program will display the files from one of the sub folders, but not all of them.  Does it have something to do with my iteration indexing of the for loop?
 
Thanks,
Adam
0 Kudos
Message 7 of 14
(4,735 Views)
Hi Adam,

I was a bit confused by your VI.  Why do you use the same number for both the second and third for loops.  Shouldn't the third for loop iterate equal to the number of files in that directory? 

Please let me know if you have any additional questions, or if I have misunderstood your VI.
Regards,
Ching P.
DAQ and Academic Hardware R&D
National Instruments
0 Kudos
Message 8 of 14
(4,708 Views)

Hi,

I changed the loop iterations to match the array size of the new files.  The program still only displays the files located in the first sub folder.  The loop iterations of the second for loop displays the correct number of iterations of the loop.  The last for loop only displays a value of one iteration.  The program seems to be unable to append all of the files in the sub folders into one array.  This is how I structured  the program:

1.  Recursive search the main folder

2   Recursive search the sub folder of the main folder

3.  Display the all the files of the sub folders.

I have been trying to think of another to structure the program, but haven't come up with one.  Is this the correct why to go about this, or is it not possible to display all the files of the sub folders?

Adam 

0 Kudos
Message 9 of 14
(4,702 Views)

Hi Adam,

Thanks for the last reply, that has helped me pinpoint the issue.  I apologize for not catching this last night.  You need to transfer your data from one loop iteration to the next via shift registers.  I think this should resolve the issue of only displaying data from the last loop iteration.

Please let me know if this does not work, or if you have any further questions.

Regards,
Ching P.
DAQ and Academic Hardware R&D
National Instruments
0 Kudos
Message 10 of 14
(4,682 Views)