%%遍历所有文件
path=uigetdir
t = cd(path); % dos命令cd重置当前路径,自行设置,其下包含全部待处理文件
allnames = struct2cell(dir); % dos命令dir列出所有的文件,用struct2cell转换为元胞数组
[m,n] = size(allnames);
for i= 3:n % 从3开始。前两个属于系统内部。
name = allnames{1,i} % 逐次取出文件名
filename = [t,'\',name] % 组成文件名
%Do your own work
end
%%遍历指定扩展名文件
clc
clear
%% 命令集
path=uigetdir
filelist=dir(fullfile(path,'*.JPG'));
n=length(filelist)
for i=1:n
strcat(path,filelist(i).name)
end