How to extract contents of multiple tar files in a loop?

5 vues (au cours des 30 derniers jours)
Susan le 1 Avr 2021
Commenté : Susan le 1 Avr 2021
Hello Everyone,
I have multiple .tar.gz files that I'd like to extract contentes of them. For one file I use
path = 'C:\Users\data\example.tar.gz';
gunzip(path, 'example');
However, I have many of these files (each one has a specific name) and I don't want to go through all of them one by one. I tried to use the following code in a for loop but no luck so far since these are not folders but .tar.gz files
D = 'C:\Users\data\';
S1 = dir(fullfile(D,'*'))
N1 = setdiff({S1([S1.isdir]).name},{'.','..'})
Any idea how I can do that?

Réponse acceptée

meghannmarie le 1 Avr 2021
Modifié(e) : meghannmarie le 1 Avr 2021
Do you mean something like this?
input_folder = 'C:\Users\data\';
file_struct = dir([input_folder '/**/*.tar.gz']);
file_names = {};
files = fullfile({file_struct.folder},file_names);
for f = 1:numel(files)
file = files{f};
  4 commentaires
Susan le 1 Avr 2021
Thank you!!!!

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur Data Import and Export dans Help Center et File Exchange


Community Treasure Hunt

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

Start Hunting!

Translated by