Skip to main content

findFullFileFromPrefix.m


% This function is part of the NMSM Pipeline, see file for full license.
%
% Finds the first instance of a file with the given prefix in the given
% directory and returns the full file path.
%
% (string, string) -> (string)
% returns the full file name with the given prefix in the directory


function fullfilename = findFullFileFromPrefix(directory, prefix)
fullfilename = '';
files = dir(directory);
for i=1:length(files)
index = strfind(files(i).name, prefix);
if(length(index)==1)
fullfilename = fullfile(directory, files(i).name);
break;
end
end
end