downloading the same file to multiple locations

조회 수: 3 (최근 30일)
Mahith Madhana Kumar
Mahith Madhana Kumar 2021년 1월 15일
댓글: Mahith Madhana Kumar 2021년 1월 15일
Hello all,
I want to download a single file from an ftp server but place multiples copies of it in different target directories in my local PC.
I was doing the following:
ftpobj = ftp('ftp.ngdc.noaa.gov');
mget(ftpobj,'README.txt', C:\Users\Desktop\folder1);
This downloads the 'README.txt' file into my target folder having the path - C:\Users\Desktop\folder1.
I would however like to have the same 'README.txt' file in multiple folders like for example in C:\Users\Desktop\folder1, C:\Users\Desktop\folder2 and C:\Users\Desktop\folder3 with the condition that the file 'README.txt' should be downloaded ONLY ONCE from the ftp server.
Is there any way to do that - i.e is it possible to download the file into multiples folders/targets using mget?

채택된 답변

Matt Gaidica
Matt Gaidica 2021년 1월 15일
Yes. Download it then use the local path and copyfile
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 1월 15일
Yes, or if you have more destinations, loop
for dest = 2 : 5
copyfile('README.txt', sprintf('%s%d', 'C:\Users\Desktop\folder', dest));
end
Mahith Madhana Kumar
Mahith Madhana Kumar 2021년 1월 15일
Thank you both.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Downloads에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by