File Exchange

image thumbnail

Search( filetype,folderpath​)

version 1.0.0.0 (1.21 KB) by anthony bobbie
Recursively searh folder path

0 Downloads

Updated 04 Mar 2015

View License

%% SEARCH Searches a folderpath and returns a list of matching filetype
% This function works only on windows machines. This is a demostration of
% how System.IO namespace can be used in MATLAB.
% filetype: file type sought after. Argument permitted can be any file type
% on windows machine e.g. '*.xls','*.m' : Use '*.*' to return all file
% types.
% folderpath: folder path to look for matching filetypes e.g 'C:\windows' ;
% note however that u much have search permission on the folder you intend
% to search.

Cite As

anthony bobbie (2020). Search( filetype,folderpath) (https://www.mathworks.com/matlabcentral/fileexchange/49922-search-filetype-folderpath), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

Jan

The message 'file type cannot be empty' does not match the test "exist(folderpath, 'dir')==7".

There is a problem with the indexing: The last element of the output is empty. Why does the FOR loop end at "file_count-1" and not "file_count"? You need the 1-based indices in the Matlab cell, but a 0-based index for the .NET array:
for x = 1:file_count
output_args{x}= char(arfi.GetValue(x-1).FullName);
end

There is no need to limit the file specifier to start with '*.' .

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux