处理数据中用到的一个matlab改文件名的小代码
// An highlighted block
close all;clc
path_origin='E:\Good good study\';
img_path_list=dir(strcat(path_origin,'*.hdf'));
img_num=length(img_path_list);
cd(path_origin);
for j=1:img_num
img_name_old=img_path_list(j).name;
sub = img_name_old(14:16);
sub2 = str2double(sub);
Date=datetime(2021,1,sub2);
formatout='yyyymmdd';
DateString = datestr(Date,formatout);
img_name_new=strcat(DateString,'.hdf');
TF = strcmp(img_name_old,img_name_new);
if ~TF
eval(['!rename' ' ' img_name_old ' ' img_name_new]);
disp( img_name_new)
end
end