How to unzip multiple files(zipped) present in different subfolders

조회 수: 26 (최근 30일)
LadyPhantom
LadyPhantom 2022년 3월 23일
편집: Stephen23 2022년 3월 23일
I need help with unzipping files that are in different subfolders.
I have:
Folder 1 -> subfolder 1 -> zipped file1(NIFTI file of T1 weighted MRI image)
Folder 1 -> subfolder 2 -> zipped file2( NIFTI file of Mask image)
I would like to extract and move the "zipped file 1" and "zipped file 2" to a single folder.
Could you please provide an algorithm or code to carry out the same.

답변 (1개)

Stephen23
Stephen23 2022년 3월 23일
inp = 'absolute or relative path to Folder 1';
out = 'absolute or relative path to the output folder';
unzip(fullfile(inp,'nameOfSubfolder1','nameOfZippedFile1'),out)
unzip(fullfile(inp,'nameOfSubfolder2','nameOfZippedFile2'),out)
  댓글 수: 2
LadyPhantom
LadyPhantom 2022년 3월 23일
There are around 1000 folders like this and I'd like to unzip all the similar way.
Stephen23
Stephen23 2022년 3월 23일
편집: Stephen23 2022년 3월 23일
The use a loop:
For example:
S = dir(fullfile(inp,'**','*.ZIP'));
for k = 1:numel(S)
F = fullfile(S(k).folder,S(k).name);
unzip(F,out)
end

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MRI에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by