Fanning Software Consulting

Fast File Searching

Facebook Twitter RSS Google+

QUESTION: I running IDL 8.2.3 on Windows 7 64-bit. I have an older program that uses Findfile to recursively find a set of filenames with a wildcard. I realize Findfile is obsolete, but it runs much faster than File_Search, especially when I am searching a directory that is on a network share. (I can't use Findfile here, unfortunately, because I have more files in my directory than Findfile can handle correctly.) For example, to return the files in a directory containing about 7000 files on a network share takes about 26 seconds on my Windows and about 0.6 seconds on a my LINUX machine. Is there any way to speed File_Search up?

ANSWER: Apparently not, but we have come up with a workaround for you. It turns out that spawning the Windows "dir" command takes much less time than using File_Search on network shares containing many files.

IDL> tic & spawn, 'dir U:\somenetworkshare\* /b /aD', found, /hide & toc
     % Time elapsed: 0.32800007 seconds.
IDL> tic & found=file_search('U:\somenetworkshare\*', count=count, /nosort) & toc
     % Time elapsed: 26.066000 seconds.

Here is a program, named ListFiles, that can be used with Windows and UNIX computers to find files on network shares quickly. It should be noted that this workaround works best when the directory contains many files to be returned. For example, if your directory contains, say, 7000 text files and you want to return all of them with File_Search, it takes about 26 seconds. But, if there are only a handful of text files in that directory, File_Search returns in about 0.3 seconds. The workaround may actually be slower than File_Search in this case.

Version of IDL used to prepare this article: IDL 8.2.3.

Written: 30 July 2013