以文件倒序命名为例
sfile_path1='C:\Users\qx\Desktop\Fund\';
file_path2='C:\Users\qx\Desktop\Fund2\';
img_path_list = dir(strcat(file_path1,'*.png'));%获取该文件夹中所有jpg格式的图像
img_num = length(img_path_list);%获取图像总数量
if img_num > 0 %有满足条件的图像
for j = 1:img_num %逐一读取图像
image_name_old = img_path_list(j).name;% 图像名
% 路径,名字,后缀
[~,name,~]=fileparts(image_name_old);
% 将文件倒序命名
image_name_new = strcat(num2str(img_num-str2num(name)+1), '.png');
image = imread(strcat(file_path1,image_name_old));
imwrite(image,strcat(file_path2,image_name_new))
end
end