Filter löschen
Filter löschen

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

6 Ansichten (letzte 30 Tage)
Thomas Kurian
Thomas Kurian am 9 Mär. 2023
Beantwortet: Thomas Kurian am 10 Mai 2023
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 Kommentare
Stephen23
Stephen23 am 9 Mär. 2023
Bearbeitet: Stephen23 am 9 Mär. 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 am 9 Mär. 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)

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Thomas Kurian
Thomas Kurian am 10 Mai 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

Weitere Antworten (2)

Sarvesh Kale
Sarvesh Kale am 9 Mär. 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 Kommentare
Thomas Kurian
Thomas Kurian am 9 Mär. 2023
Bearbeitet: Thomas Kurian am 9 Mär. 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 am 9 Mär. 2023
Bearbeitet: Stephen23 am 9 Mär. 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.

Melden Sie sich an, um zu kommentieren.


Thomas Kurian
Thomas Kurian am 9 Mär. 2023
Bearbeitet: Thomas Kurian am 9 Mär. 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

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by