标签:
把符合的文件路径保存到fp中,FileType为指定文件的类型,MainPath为文件夹的路径
function Path=ReadFile(fp,MainPath,FileType)
%%%%%%%%%%%%%%
%MainPath为主路径,FileType为需要读取的文件类型
PathFileFormation=dir(MainPath);
PathNumber=numel(PathFileFormation);
for LoopPathNumber=1:PathNumber
if( isequal( PathFileFormation( LoopPathNumber ).name, ‘.‘ ) || ...
isequal( PathFileFormation( LoopPathNumber ).name, ‘..‘ )) % 如果不是目录跳过
continue;
elseif PathFileFormation( LoopPathNumber ).isdir
Path=fullfile(MainPath,PathFileFormation(LoopPathNumber).name);
Path=ReadFile(fp,Path,FileType);
else
Path=fullfile(MainPath,[‘*‘,FileType]);
images=dir(Path);
for i=1:numel(images)
fprintf(fp,‘%s\n‘,fullfile(MainPath,images(i).name));
end
break;
end
end
标签:
原文地址:http://www.cnblogs.com/matrix314/p/5625361.html