使用matlab来修改图片文件名

%把热身数据图片名字 从1-720转换为2009-2728
clear all
file_path1=‘K:\科目4\科目四-热身数据\科目四热身赛数据\images’;
file_path2=‘K:\科目4\科目四-热身数据\科目四热身赛数据\new_name_image’;
img_path_list = dir(strcat(file_path1,’*.tif’));%获取该文件夹中所有jpg格式的图像
img_num = length(img_path_list);%获取图像总数量

if img_num > 0 %有满足条件的图像
for j = 1:img_num %逐一读取图像
image_name_old = img_path_list(j).name;% 图像名
j=j+2008;
image_name_new = strcat(num2str(j),’.tif’);
image = imread(strcat(file_path1,image_name_old));
imwrite(image,strcat(file_path2,image_name_new))
end
end

你可能感兴趣的:(matlab学习)