Find all files of a particular extension in folder AND subfolders
BMangum
I can load all files from a given folder no problem.
The issue is when there are subfolders with varying numbers of levels.
If Igor cannot do this directly can I use something analogous to the Matlab "system" command?
I would like a way to return the full path to each found file, any suggestions?
August 15, 2012 at 12:27 pm - Permalink
Thanks for the tip. This works pretty well but is not quite as general as it could be.
I am dealing with a system that has lots of users storing data all over the place.
Imagine the following Directory structure (I have tried to show levels by size and spacing):
E:Data:
a.txt
b.txt
sub1:
c.txt
d.txt
sub2:
e.txt
sub3:
f.txt
This example will only find file f.txt, and will not find a-e.txt.
This is definitely a starting point, I'll see what I can do.
August 15, 2012 at 03:00 pm - Permalink
1) In your function listthem use
indexedfile
to list all the txt files. Append the list to a string, thefilesThe function prototype is:
String directoryStr, &theFiles
Note that the ampersand means that you are passing by reference, not by value. The entire string gets added to after you return from the function.
2) Then list all the directories in the current directory using
indexeddir
. Iterate through all the directories in afor
loop calling listthem recursively. thefiles string gets added to as you walk the tree.3) You have to call the function with a zero length string to start with.
August 15, 2012 at 05:35 pm - Permalink