5.0

5.0 | 7 ratings Rate this file 72 downloads (last 30 days) File Size: 2.61 KB File ID: #19550

Recursive directory listing

by Gus Brown

 

11 Apr 2008 (Updated 14 Apr 2008)

Code covered by BSD License  

Directory listing with a difference, supports directory wildcards.

Download Now | Watch this File

File Information
Description

Lists the files in a directory and its sub directories.

Ok, so there are many functions like this one already on the file exchange, but this one uses a slightly different wildcard naming system that some people may find useful.

For example,

rdir('C:\Program Files\Windows*\**\*.dll');

will find all dll files in the directories starting with 'C:\Program Files\Windows' and all the dll files in the sub directories below them.

One can filter the list based on the file size and date.

Using the function to find files modified sometime today in the windows directory

rdir('C:\Win*\*','datenum>floor(now)');

Include the sub directories.

rdir('C:\Win*\**\*','datenum>floor(now)');

Or you could use it to find all the no zero-byte processed csv data files for the data recorded in April 2008.

rdir('data\test_200804*\csv\*.csv','bytes>0');

this finds files like...
data\test_20080401\csv\08h00.csv
data\test_20080401\csv\16h00.csv
data\test_20080402\csv\08h00.csv
data\test_20080402\csv\16h00.csv

Acknowledgements
This submission has inspired the following:
Find 'orphaned' m-files, Find repeated m-file names, Recursive directory walk with -exec (UNIX type)
MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
13 May 2008 Dimitri Shvorob

Great job! Did what neither FUF nor DIRR (earlier FEX submissions) managed to do, and surprisingly fast, too.

12 Jun 2008 Dennis Olly

FUF was great, but failed on folders with a '.' in the name, eg '\recon_P20992.7\'. Rdir is excellent!
 

16 Jul 2008 Imaging Coderguy

I used FUF extensively in the past, and though it did the job, its slowness and quirks were problematic. RDIR on the other hand is so slick and well-made that it may as well be a mathworks-made function. Great work!

29 Jul 2008 Phillip Feldman

Excellent! Just what I was looking for.

The double star syntax is a bit strange. I'd like to suggest that a slightly cleaner and more flexible mechanism for controlling the recursive searching would be an optional argument that specifies the maximum folder depth of the search.

22 Jan 2009 Ashish Uthama  
24 Jun 2009 Oleg Komarov  
06 Aug 2009 Bart Geurten  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
path Gus Brown 22 Oct 2008 09:57:21
directories Gus Brown 22 Oct 2008 09:57:21
files Gus Brown 22 Oct 2008 09:57:21
unusual Gus Brown 22 Oct 2008 09:57:21
recursion Gus Brown 22 Oct 2008 09:57:21
directory Gus Brown 22 Oct 2008 09:57:21
utilities Gus Brown 22 Oct 2008 09:57:21
difference Gus Brown 22 Oct 2008 09:57:21
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com