Unzipping code in a loop within another loop?

8 ビュー (過去 30 日間)
George Choa
George Choa 2017 年 7 月 26 日
コメント済み: Jan 2017 年 7 月 28 日
Quite a beginner in MATLAB so finding it a little difficult to construct the code for this... I currently have zipped files within folders within folders, which I need to unzip before manipulating the data further. I believe I need some form of a loop within a loop for this to work? But have no idea how to script this! Any help would be appreciated!

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 7 月 26 日
Since you are a beginner, I will assume you are running R2017a or later.
projectdir = 'TopLevelFolder'; %can be fully qualified
%this next requires R2017a or later
dinfo = dir( fullfile( projectdir, '**', '*.zip') ); %find all .zip underneath the projectdir.
%then
for K = 1 : length(dinfo)
unzip( dinfo(K).name, dinfo(K).folder ); %still needs R2017a or later
end
  2 件のコメント
George Choa
George Choa 2017 年 7 月 28 日
Hi Walter, so would this not work with R2016b?
Jan
Jan 2017 年 7 月 28 日
It works well under R2016b. I assume Walter means the '**' key in dir, but this was support in R2016b as well as the field 'folder'. If you are in doubt, George, simply try to run the code: If it runs, it runs.

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

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by