Be the first to rate this file! 12 downloads (last 30 days) File Size: 1.62 KB File ID: #20814

Recursive Directory Function Execution

by Rodney Thomson

 

22 Jul 2008 (Updated 22 Jul 2008)

Code covered by the BSD License  

Recurse through all directories executing the supplied function

Download Now | Watch this File

File Information
Description

Recurses through each directory, passing the full directory path and any extraneous arguments (varargin) to the specified function.

Call Sequence : directoryRecurse(directory, function_pointer, varargin)

IE: To execute the 'rmdir' command with the 's' parameter over 'c:\tmp' and all subdirectories:

directoryRecurse('c:\tmp', @rmdir, 's');

Another useful example, add 'c:\matlab' and all sub directories to the Matlab path:
directoryRecurse('c:\tmp', @addpath);

MATLAB release MATLAB 7.0.4 (R14SP2)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
30 Jul 2008 Thierry Dalon

Idea is good but no concatenated output like in filefun FX9723.
only interesting for functions with no output.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
path Rodney Thomson 22 Oct 2008 10:11:15
directories Rodney Thomson 22 Oct 2008 10:11:15
files Rodney Thomson 22 Oct 2008 10:11:15
recursion Rodney Thomson 22 Oct 2008 10:11:15
function handle Rodney Thomson 22 Oct 2008 10:11:15
recurse Rodney Thomson 22 Oct 2008 10:11:15
utilities Rodney Thomson 22 Oct 2008 10:11:15
function handle Linda 06 Apr 2009 12:38:23
recurse Linda 06 Apr 2009 12:38:24
recursion Linda 06 Apr 2009 12:38:25
utilities Linda 06 Apr 2009 12:38:27
files Linda 06 Apr 2009 12:38:28
directories Linda 06 Apr 2009 12:38:29
 

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