Thanks to Kit Baum, a new version of filelist is now available on SSC.
filelist searches a directory for files that match a specific pattern and continues searching for files recursively in all its subdirectories. Search results either replace the data in memory or are saved as a Stata dataset on disk.
This new version is written in Mata to overcome a problem with directories that contain a very large number of files (whose names cannot all fit into a single macro).
I've also found a way to discover the file size with virtually no overhead, so the search results include the file size in bytes as well.
Here's an example where I search my whole Documents directory for all Stata datasets
To update to the new version, type in Stata's command window:
To install filelist for the first time, type
filelist searches a directory for files that match a specific pattern and continues searching for files recursively in all its subdirectories. Search results either replace the data in memory or are saved as a Stata dataset on disk.
This new version is written in Mata to overcome a problem with directories that contain a very large number of files (whose names cannot all fit into a single macro).
I've also found a way to discover the file size with virtually no overhead, so the search results include the file size in bytes as well.
Here's an example where I search my whole Documents directory for all Stata datasets
Code:
. cd "/Users/robert/Documents"
/Users/robert/Documents
. filelist, pattern(*.dta)
Number of files found = 7675
. sum fsize
Variable | Obs Mean Std. Dev. Min Max
-------------+--------------------------------------------------------
fsize | 7672 5222725 4.10e+07 278 1.52e+09
. dis %20.0gc r(sum)
40,068,745,379
Code:
adoupdate filelist, update
Code:
ssc install filelist

Comment