引言:
将采集到的图片按序自动重命名
代码:
function renamePics(strFile)
strPic=strFile;
dis = dir([strPic,'\*.bmp']);
nms = {dis.name};
for i = 1:length(nms)
old_name = [strPic,nms{i}]; %获取每张图片的名字
new_name = [strPic,num2str(i),'.bmp'];
if(strcmp(old_name,new_name))
break;
else
movefile(old_name,new_name);
end
end
补充:
1)strFile:文件夹地址,例:imgDataPath=“C:\Users\采图时间测试”;
2)图片如果不是bmp格式需要修改代码中的后缀名