MATLAB: Renaming Files

rename fille

I used 7 zip to split large excel files. It gave them to me in the following format: naic1.xlsx.001,…naic1.xlsx.029 for file 1 naic2.xlsx.001,…naic2.xlsx.030 for file 2 etc… naic29.xlsx.001,…naic2.xlsx.006 for file 29
I tried all the renaming functions in file exchange without any luck. I want to rename them as naic1.xlsx …..naic(a consecutive number I think it will be 833).xlsx Any help with that is greatly appreciated

Best Answer

Something alone the line as below. Proceed with caution.
count=1;
for k=1:29
Files=dir(['naic',num2str(k),'.xlsx.*']);
for j=1:length(Files)
movefile(Files(j).name,['naic',num2str(count),'.xlsx']);
count=count+1;
end
end
Related Question