原文件名格式:汉字名称+数字+.dcm,例如:杨勇23.dcm
修改后文件名格式:IM+三位数字+.dcm,例如:IM023.dcm
%% 重命名需打开当前文件夹再运行
% 直接读取即可 不需要重新命名
files = dir('*.dcm');
len=length(files);
for i=1:len
oldname=files(i).name;
%一次读取文件名
numstr=strrep(oldname,'杨勇','');%字符串替换newStr = strrep(str,old,new)
numstr=strrep(numstr,'.dcm','');
num=str2num(numstr);
newname = sprintf('%s%03d%s','IM',num,'.dcm');%E:\kidney\Data\Chouchongxian\
command = ['rename' 32 oldname 32 newname];
status = dos(command);
if status == 0
disp([oldname, ' 已被重命名为 ', newname])
else
disp([oldname, ' 重命名失败!'])
break;
end
end