%% 检查路径下所有文件 % pathlist :文件夹列表 % n:第n个文件 functioncheckdir(pathlist,n,exincludedir,dstpath) for ii=n:length(pathlist) ptmp=pathlist(ii); %% 排除 if(sum(ptmp.name==exincludedir)) continue; end nextptmp=[ptmp.folder,'\',ptmp.name];%子路径 if(isfolder(nextptmp))%是文件夹 nextptmp=[ptmp.folder,'\',ptmp.name];%子路径 checkdir(dir(nextptmp),1,exincludedir,dstpath); end %后缀 [~,~,abc]=fileparts(ptmp.name); % copy if(abc==".md") srcp=[ptmp.folder,'\',ptmp.name]; if isfolder(dstpath)~=1 mkdir(dstpath) end copyfile(srcp,dstpath); end end end