How to Unzip Files in subfolder and delete particular files

6 views (last 30 days)
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?

Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!