文件处理代码如下:
x = dir('D:\groundtruth\MVI_9331\img\*.jpg');%需要修改的文件目录
for i = 1:length(x)
x1 = x(i).name;% 提取第一个文件
x2 = i;
a = sprintf('%05d', i);%文件命名如00001
x3 = num2str(a);% 转换为字符串
x4 = char('.jpg');
x5 = strcat(x3, x4);% 文件名00001.jpg
copyfile(['D:\groundtruth\MVI_9331\img\' x1],['D:\groundtruth\MVI_9331\img1\' x5]);% 重命名文件保存到另一个文件夹
%movefile(['D:\groundtruth\MVI_9331\img\'
%x1],['D:\groundtruth\MVI_9331\img\' x5]);%不保留源文件
end