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!

 採用された回答

Voss
Voss 2023 年 8 月 13 日

1 投票

Here's one way:

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

2 件のコメント

Ewelina Lorenc
Ewelina Lorenc 2023 年 8 月 13 日
Thank you, it works perfectly!
Voss
Voss 2023 年 8 月 13 日
You're welcome!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

質問済み:

2023 年 8 月 13 日

コメント済み:

2023 年 8 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by