Renaming Files

2 次查看(过去 30 天)
Danielle Leblanc
Danielle Leblanc 2011-8-6
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

采纳的回答

Fangjun Jiang
Fangjun Jiang 2011-8-6
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
  3 个评论
Fangjun Jiang
Fangjun Jiang 2011-8-6
I think I might know the problem. Copy all your files to a temporal folder and run the code again. This time it uses movefile() and it also limit the files returned by dir(). You should also not to expect the code will work without any modification. I don't have the exact folder/files as you have. You should understand the code, do a little debugging and make it work.
Fangjun Jiang
Fangjun Jiang 2011-8-6
Please note I've modified the code.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by