function MoveFileToMainPath(main_path,sub_path,fileExtension)
%函数内容
maindir = dir(sub_path);%列举文件夹中所有内容
sub_main_path = sub_path;%保存当前子文件夹路径
for i = 1 : length(maindir )
if isempty(strfind(maindir( i ).name, '.' ))% 判断是否为文件夹
sub_path = fullfile(sub_main_path,maindir( i ).name);%生成当前文件夹内的子文件夹路径
MoveFileToMainPath(main_path,sub_path,fileExtension);%回调
elseif ~isempty(strfind( maindir( i ).name,fileExtension)) && ~strcmp(main_path,sub_main_path)%判断是否为子文件夹内的文件
subFile = fullfile(sub_path, maindir( i ).name);
movefile(subFile,main_path)%剪切到主文件夹中,如果是拷贝,用copyfile
end
end