gunzip subfolders at once

3 Ansichten (letzte 30 Tage)
Dave
Dave am 12 Okt. 2021
Kommentiert: Dave B am 12 Okt. 2021
Hello, I have gz files stored in many sub-sub-folders; is there way I can gunzip all files at once into a single folder single_folder without looping over each sub-sub-folder?
C:\Main\Data\subf1\subf2\subf3\subf4\subf5\subf6
The gz files are in subf6
To use gunzip I have to be in subf6
filenames = gunzip(????,'single_folder');
Is there a way to gunzip standing in subf1?

Akzeptierte Antwort

Dave B
Dave B am 12 Okt. 2021
Bearbeitet: Dave B am 12 Okt. 2021
You can pass wildcards to gunzip (note that the first example does exactly this):
fp = 'C:\Main\Data\subf1\subf2\subf3\subf4\subf5\subf6';
gunzip(fullfile(fp,'*.gz'),'single_folder'); % or maybe you want the output to be fullfile(fp, 'single_folder')?
  3 Kommentare
Dave
Dave am 12 Okt. 2021
on a second note, that is helpful enough since looping does not override single_folder
danke
Dave B
Dave B am 12 Okt. 2021
Sounds like it works, sorry I misunderstood the question!
For future reference an alternative strategy is to build up the list of files and pass the list to gunzip
fl=dir(fullfile(fp,'**/*.gz')
fl=fullfile({fl.folder},{fl.name});
gunzip(fl,'single_folder')

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Downloads finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by