matlab多个文件图写到一个文件夹
clear;
clc;
%fin = fopen(\’E:/Personal/Desktop/test1.txt\’,\’wt\’);
imgDataPath = \’E:/Personal/Desktop/zhong/\’;
outdir = \’E:/Personal/Desktop/photo3\’;%图片路径
imgDataDir = dir(imgDataPath); % 遍历所有文件
for i=0:499 %********100
imgDir = dir([imgDataPath,\’/\’, num2str(i) \’/*.jpg\’]); % ********100
for j =1:length(imgDir)%图
img = imread([imgDataPath,\’/\’, num2str(i) \’/\’ imgDir(j).name]);%*********100
newname = [outdir,\’/\’,num2str(i),\’_\’,imgDir(j).name];%图片路径********100
imwrite(img,newname);%图片
end
end