필터 지우기
필터 지우기

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에서 File Operations에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by