Is it possible to zip a list of files over ftp?

3 views (last 30 days)
Hello
I have a camera saving a series of images on a remote computer that I would like to download. I am currently using ftpobj and mget running in a loop to get all the files which is quite time consuming. I was wondering if it is possible to zip the files remotely through matlab and just use mget for the .zip file
  2 Comments
Stephen23
Stephen23 on 9 Mar 2023
Edited: Stephen23 on 9 Mar 2023
"I was wondering if it is possible to zip the files remotely through matlab and just use mget for the .zip file"
For this to make any sense, the zipping would need to be performed by some application at the remote end (otherwise zipping using a local application would still require transferrring all file uncompressed data remote->local->zip locally... not much sense in that). So you would have to get MATLAB to request a remote application to perform the zip, before using FTP to transfer that zip file. You have not told us what OS or applications are available at the remote end.
Note that "FTP" stands for "File Transfer Protocol", and it has no provision for calling arbitrary applications at the remote end:
Thomas Kurian
Thomas Kurian on 9 Mar 2023
True. the remote computer is a linux computer so I can run zip through a bash script for example. But then the problem becomes getting Matlab to execute a bash script remotely. Is that possible? (Sorry this becomes a change of topic)

Sign in to comment.

Accepted Answer

Thomas Kurian
Thomas Kurian on 10 May 2023
I found this on File Exchange which works for me now, but over ssh instead of ftp
https://www.mathworks.com/matlabcentral/fileexchange/35409-ssh-sftp-scp-for-matlab-v2

More Answers (2)

Sarvesh Kale
Sarvesh Kale on 9 Mar 2023
See if the following documentation helps, zip function matlab document . mget function in matlab. Example code usage is shown below
% assume that your folder has jpeg images you want to compress
% on remote computer
zip('backup',{'*.jpeg','*.jpg'}) % compress all files which are jpeg or jpg format to backup.zip
execute the below code on your local machine
% on local machine
s = ftp('your host address'); % enter your host ftp address in place of 'your host address' in single commas
mget(s,'backup.zip') ;
I hope the above helps in your query.
Thank you.
  4 Comments
Thomas Kurian
Thomas Kurian on 9 Mar 2023
Edited: Thomas Kurian on 9 Mar 2023
Yes. I guess I will have to do something like this in the end. This solves my problem, but I guess the answer to the question is that it is not possible entirely in Matlab
Stephen23
Stephen23 on 9 Mar 2023
Edited: Stephen23 on 9 Mar 2023
"but I guess the answer to the question is that it is not possible entirely in Matlab"
This is not a MATLAB problem, but a conceptual problem. Zipping requires the CPU to process the data. MATLAB is running on your local CPU. So to use your local MATLAB to zip the data, you would need to transfer all of the data to your local computer, where your local CPU is, which can then locally zip the data. A local app running on a local CPU cannot suddenly jump through space and run on a remote CPU, to process some data there.
It has nothing to do with MATLAB, it applies to all applications.

Sign in to comment.


Thomas Kurian
Thomas Kurian on 9 Mar 2023
Edited: Thomas Kurian on 9 Mar 2023
So As Stephen23 points out this is not a matlab issue. I can't get matlab to zip files on a remote computer without transferring them first. So I need to log in to that computer and run a script of some kind to do the zipping for me.
this thread was helpful as to get that to work:

Tags

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!