How is it possible to Zip, Download and Delete (ZDD) a file in WinSCP?

For example, your local dir is Desktop and your remote dir (the one in your server machine) is, say, /var/www/html and you want to zip and download a particular dir or file, and then you want it to be removed the moment the download was finished.

enter image description here

To further explain, in linux I could do, for example:

zip -r /var/www/html/dr.zip /var/www/html
scp /var/www/html/dr.zip USER@IP:/location
rm /var/www/html/dr.zip

I need similar thing for WinSCP yet I'm aware that the WinSCP download mechanism should be used and that it is different then the Nix scp utility.

My question:

Do you know a way to achieve this with WinSCP?


2 Answers 2


There's no way to ZIP files over any file transfer protocol (SFTP, FTP, SCP or WebDAV). That's why there's no such function in WinSCP, as it cannot be implemented reliably.

Though, if you have a shell access to the server, you can use a shell command to ZIP the files. That's actually, what the Tar/GZip custom command does.

If you want it in one-go (zip-and-download), there's now a WinSCP extension that does exactly this:
Archive remote files to ZIP archive, download it, and optionally extract it.


Under custom commands, there is now an option to "Archive and Download" a file or directory. You could use that command and delete the file after the download.

If you are going to do this often and really want to auto-delete after download, you could modify the powershell script to delete the files after download. I will explain this for WinSCP version 5.17.6

Open this file in an editor: c:\Program Files (x86)\WinSCP\Extensions\ArchiveDownload.WinSCPextension.ps1

Line 151 which should contain:

$session.GetFiles($source, $target, $True).Check()

Add these lines after that line:

$commands = "rm -rf $filesArgs"
$result = $session.ExecuteCommand($commands)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy