matlab大批量移动图片
起因:要从服务器上下载图片,图片在服务器上是一个文件夹,但我想按照年月日分开来
于是:首先把图下到一个文件夹里
%% move file
sourcedir = 'F:\coffee\T6049all\T6049\201809\0906';
destinDir = 'F:\coffee\T6049all\T6049';
imagelist = dir(sourcedir); % 从第三个开始才是图片
imgLength = length(imagelist); % 图片数+2
for i = 3: imgLength
name = imagelist(i).name;
monthdir = name(:,10:15); %年月
datedir = name(:,14:17); % 月日
imagepath = fullfile(sourcedir, name); %图片路径,移动图片路径
finDesDir = fullfile(destinDir,monthdir,datedir);
movefile(imagepath,finDesDir); %movefile 使用需加括号
end
成功~~
浙公网安备 33010602011771号