起因:要从服务器上下载图片,图片在服务器上是一个文件夹,但我想按照年月日分开来
于是:首先把图下到一个文件夹里
%% 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
成功~~
本文介绍了一个MATLAB脚本,用于从服务器下载图片并按照年月日进行分类存档。通过遍历图片列表,提取每张图片的日期信息,并创建相应的文件夹进行存放。
6251

被折叠的 条评论
为什么被折叠?



