Reputation: 354
I have a directory
C:/Simulations/Dyno
And Dyno
has folders and files lets say
C:/Simulations/Dyno/Folder1
C:/Simulations/Dyno/Folder2
C:/Simulations/Dyno/foo.txt
C:/Simulations/Dyno/foo2.txt
In Matlab how would I zip the folder Dyno
but exclude the folder2
and foo.txt
?
I want Dyno
to be a directory in the zip file and not just folder2
and foo.txt
.
Upvotes: 2
Views: 1044
Reputation: 112769
You need to specify the full path of all files and folders you want to zip, and pass them as a second argument to Matlab's zip
function in the form of a cell array. The base folder is passed as a third argument. The resulting zip file is created in your current folder.
In your example:
filename = 'Dynozip'; %// name of generated zip file
list = {'Dyno\Folder1','Dyno\foo.txt'}; %// files and folders to be included
basefolder = 'C:\Simulations'; %// base folder
zip(filename, list, basefolder)
Upvotes: 2