Hey, hope you doing well.
I have this code that goes to a website database, downloads and unzips all the files there. Each zip file comes with hundreds of txt files and two excel files. I only need the two excel files, however its not a problem if the code downloads the txt files aswell. The problem is that the excel files have all the same name, so when i run the code i get in the folder thousands of text files and only two excel files. The code is overwriting the excel files when unziping.
How can i make matlab, after unziping, to change the name of the excel files so they wont overwrite?
This is the script i have.
web ='https://sensors.rivm.nl/benchmark/';
data = webread(web);
files = regexpi(data,'[A-Z_0-9]+.zip<','match');
for k=1:numel(files)
file = files{k} ;
unzip([web file(1:end-1)])
end
Thank you for your help.

 채택된 답변

MJFcoNaN
MJFcoNaN 2022년 4월 18일

1 개 추천

the function of unzip allows setting an output folder, for example:
unzip([web file(1:end-1)], file(1:end-5))

댓글 수: 4

Tiago André
Tiago André 2022년 4월 18일
편집: Tiago André 2022년 4월 18일
Could i unzip to an output folder with the same name of the original zip file?
Tiago André
Tiago André 2022년 4월 18일
편집: Tiago André 2022년 4월 18일
How? Could you please give and example in a script? I have never used that functions before
MJFcoNaN
MJFcoNaN 2022년 4월 19일
I think the code is what you need exactly. Doesn't it work?
Tiago André
Tiago André 2022년 4월 19일
Yes, it worked. Thank you for your help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

제품

태그

질문:

2022년 4월 18일

댓글:

2022년 4월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by