5.0

5.0 | 1 rating Rate this file 12 downloads (last 30 days) File Size: 9.83 KB File ID: #20597

Improved file hounding

by Maurizio De Pitta'

 

07 Jul 2008 (Updated 02 Sep 2008)

No BSD License  

Search any file in current directory and subdirectories according to specified criteria

Download Now | Watch this File

File Information
Description

% filename : filehound.m
%==========================================================================
% syntax:
% filelist = filehound(filespec)
% or: filelist = filehound
% for default search for *.m files
%
% description : recursively examines directories for presence of files
% matching the filter defined by input parameter 'filespec'
%
% parameters in : filespec = (optional) filter for filenames default = '*.m'
% filespec can be of any kind: a wild card can be used both for filename
% and for extension.
%
% Examples:
% filelist = filehound('*')
% filelist = filehound('*.*')
%
% Search for all files in current directory and subdirectories
%
% filelist = filehound('myfile')
% filelist = filehound('myfile.*')
%
% Search for all files whose name is 'myfile' independently from extension
%
% filelist = filehound('*.ext')
%
% Search for files with specific extension 'ext'
%
% Search of file is powered also by wild-card handling (i.e.: '*'). The
% only assumption is that the current program assumes that '*' is at least
% a permitted char, i.e. '*' cannot be an empty string. In this way: 'ab*c'
% cannot be equivalent to 'abc' in the search. Moreover '*abc' refers to
% the last part of a string, 'ab*c' sets constraints on first two letters
% of the string and the last letter, 'abc*', requires that the first three
% letters of the string are 'abc'. The string here is meant both filename
% and extension. Hence possible calls of filehound can be:
%
% filelist = filehound('*x.m*t')
% filelist = filehound('a*x.mt*')
% filelist = filehound('ax*.*mt')
% ...
% ...
% and all the other possbile combinations. Only one wild-card for filename
% and extension is allowed.
%
% parameters out: filelist = cell array with paths for specified files
%
% NOTE: the code is not optimized - hence suggestions for further improvement are welcomed.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
filehound

MATLAB release MATLAB 7.2 (R2006a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
26 Jul 2008 Luis Marshall

Easy routine, very practical and effective.

01 Aug 2008 Thierry Dalon

it seems the author does not know filesep?

01 Sep 2008 Maurizio De Pittà

Hi everybody, I have uploaded a new version that uses 'filesep'. Thanks to Thierry Dalon for the nice suggestion.

Please login to add a comment or rating.
Updates
02 Sep 2008

Suggestion by Thierry Dalon has been followed. the file now adopts 'filesep' and it should be bug free. Length of code is remarkably shortened and global variables have been reduced accordingly.

Tag Activity for this File
Tag Applied By Date/Time
path Maurizio De Pitta' 22 Oct 2008 10:09:13
directories Maurizio De Pitta' 22 Oct 2008 10:09:13
files Maurizio De Pitta' 22 Oct 2008 10:09:13
file Maurizio De Pitta' 22 Oct 2008 10:09:13
hound Maurizio De Pitta' 22 Oct 2008 10:09:13
wildcard Maurizio De Pitta' 22 Oct 2008 10:09:13
search Maurizio De Pitta' 22 Oct 2008 10:09:13
utilities Maurizio De Pitta' 22 Oct 2008 10:09:13
 

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