007
007

Reputation: 2186

SFTP - WinSCP: Zip a file/folder

I'm transferring a file to SFTP and then trying to zip it with WinSCP. It's not working.

After my put command, I'm using the following command.

zip -r "!?&SFTP Folder Path\MyFile.txt:?SFTP Folder Path\MyFile.zip!" !&

What am I doing wrong? What should I be doing? If I only want to zip a/any file with specific extension or folder, what changes do I make?

Update:

I'm getting the following log output after a file has been copied over to the sftp ...

batch continue Searching for host... 
Connecting to host... 
Authenticating... 
Using username "admin". Authenticating with pre-entered password. Authenticated. Starting the session...

I'm using the following code after put cmd line.

option batch continue 
call zip -r "/sftp folder/Myfile.zip" Myfile.csv 
close 
exit 

Upvotes: 1

Views: 8324

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202494

Your syntax is a custom command. The custom commands is a GUI feature of WinSCP, it has nothing to do with the scripting.

In WinSCP scripting use the call command.

call zip -r /path/MyFile.zip file1.dat file2.dat ...

Though make sure you are allowed to execute shell commands on the server.

Upvotes: 1

Related Questions