How to Unzip Files in subfolder and delete particular files
조회 수: 6 (최근 30일)
이전 댓글 표시
Hello,
I want to create a unzip code that unzips zip in subfolders too
Example : I have this folder A, inside folder A is folder B C D. Inside folder B is 1.zip and folder C is 2.zip and so on
I have this following code
uiwait(msgbox('Pick a folder on the next window that will come up.'));
files = fullfile('D:\','Proyekan');
selpath = uigetdir(files);
if selpath == 0
return;
end
projectdir = selpath;
dinfo = dir( fullfile( projectdir, '**', '*.zip') ); %find all .zip underneath the projectdir.
%then
parfor K = 1 : length(dinfo)
unzip(fullfile(dinfo(K).folder,dinfo(K).name),selpath);
end
files = dir(projectdir);
deletedfiles = 0;
for itr = 1:length(files)
if files(itr).bytes<1000000 && ~files(itr).isdir
files.name
delete(fullfile(files(itr).folder, files(itr).name))
deletedfiles=deletedfiles+1;
end
end
deletedfiles
The problem is, when I run the code, The extracted files will be in the A folder while I want it to be inside the B, C, D folder.
Any idea how to fix this?
댓글 수: 2
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!