10 Jul 2012 07:12 AM |
|
hi there,
I'm trying to figure out if there is a way to return only the .txt files from a specified dir and not the subdirs within.
For example.
I have a dir c:\data\ containing text.txt and another dir called 'other'
In c:\data\other\ is 2 other .txt files.
I am using file_search but I only want to retrieve the full path for text.txt and not the other .txt files.
Another way to look at it is, is it possible to only search a dir and not its subdirs for files based on extension?
I'm pretty new to IDL but have used Matlab quite a bit. I know the Matlab function for this but is there an equivalent in IDL...
Thanks.
Norris
|
|
|
|
Deleted User New Member
Posts:  
10 Jul 2012 12:16 PM |
|
Hi Norris,
One way is to 'hard code' the directory before doing a file search. It could look something like this:
IDL> cd, 'c:\TEMP\'
IDL> t=file_search(*.txt)
For something more explicit you may have to use a combination of IDL functions. In the Help Contents search box type in the following to see what is available: file_
|
|
|
|
Deleted User New Member
Posts:1  
11 Jul 2012 12:49 AM |
|
Hi,
print,file_search('c:\data\*.txt')
should do it in one line.
|
|
|
|
Deleted User New Member
Posts:  
12 Jul 2012 04:40 AM |
|
Thanks! that did the trick.
My mistake was trying file_search(path, *.txt) so it was searching in all subdirs.
Silly mistake.
|
|
|
|