How to make loop over numbered folders?

Hi,
I have a folder which contains subfolders named c001 to c100. I need to compress each of them into zip file. So basically I need to run this function:
zip('c001','c001');
but making it automatically change to 002, 003 etc.
Thank you for your help!

 Respuesta aceptada

Voss
Voss el 13 de Ag. de 2023

1 voto

Here's one way:

for ii = 1:100
    str = sprintf('c%03d',ii);
    zip(str,str)
end

2 comentarios

Ewelina Lorenc
Ewelina Lorenc el 13 de Ag. de 2023
Thank you, it works perfectly!
Voss
Voss el 13 de Ag. de 2023
You're welcome!

Iniciar sesión para comentar.

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Preguntada:

el 13 de Ag. de 2023

Comentada:

el 13 de Ag. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by