I have a list of files named ######-######-####XX, where # is an arbitrary number (same for all files), and XX is 01:20. I'm trying to rename all the files by adding 1 to the frame number, so the files will effectively go from 02:21. I tried using the code below, but soon realized that adding 1 to 9 will not make 19 go to 20. Does anyone have a better solution for this? Thanks in advance.
list=dir('*.dcm')names={list.name}for m=1:length(list) revnames=names(end:-1:1) [~,name,ext]=fileparts(revnames{m}) OldName=[name,ext] A=num2str(name) A(end)=(A(end)+1) NewName=[A,ext] copyfile(OldName,NewName) clear Aend
Best Answer