Renaming Files

2 visualizaciones (últimos 30 días)
Danielle Leblanc
Danielle Leblanc el 6 de Ag. de 2011
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

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 6 de Ag. de 2011
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 comentarios
Fangjun Jiang
Fangjun Jiang el 6 de Ag. de 2011
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 el 6 de Ag. de 2011
Please note I've modified the code.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by