Changing input name to save data from zip files into a data cell?
Show older comments
I want to take information from a bunch of zip files and store the names of their contained files into a data cell. But I am not sure when using the "unzip()" function how I can do this.
I have multiple zip files that have the same name, except there is one number at the end of each file name that continually goes up. Is there any way to right a loop that will change the name of the input?? For example something like:
for i = 1:100
data(i,1) = unzip(filename(i));
end
in a way that this would be read as
filename1 filename2 filename3 . . . .
any help would be appreciated, and I can clarify more if you'd like.
Answers (1)
"Is there any way to right a loop that will change the name of the input??"
Of course, just follow the advice in the MATLAB documentation:
Note that if you want to use dir and want the files listed in alphanumeric order then you can download my FEX submission natsortfiles to do this:
P = 'directory where the files are';
S = dir(fullfile(P,'*.zip'));
S = natsortfiles(S); % download from FEX
for k = 1:numel(S)
S(k).data = unzip(fullfile(P,S(k).name));
end
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!