Topic "Automatically zip folder before SFTP transfer"

Author Message
gee
[View user's profile]

Joined: 2016-06-22
Posts: 1
Hi,

I am having difficulty getting my WinSCP script to compress a folder containing large CSVs and unfortunately have no found an answer in the forum posts.

I am using a wrapper script to create a Windows batch file which runs as a scheduled task.

I am unsure whether I need to create a WinSCP custom zip command or whether I am even on the right track trying to compress the folder within my script. Any advice would be appreciated!

Here is my current code:

SET SFTPURL=sftp://username:pass@mySite.com.au

REM Local directory where CSV files are found
SET LCD=D:\Report\Today

REM The local directory where script files are kept
SET WORKDIR=C:\Scripts\SFTP

REM change to SFTP folder
CD "%WORKDIR%"

REM Delete batch file config
DEL "%WORKDIR%\SFTP_today.txt"

REM Create text file with transfer parameters
REM Connect
ECHO option batch on > "%WORKDIR%\SFTP_today.txt"
ECHO option confirm off >> "%WORKDIR%\SFTP_today.txt"
ECHO open %SFTPURL% -hostkey="ssh-rsa 123abc">> "%WORKDIR%\SFTP_today.txt"

REM change to remote folder
ECHO cd Today >> "%WORKDIR%\SFTP_today.txt"
REM change to local folder
ECHO lcd %LCD% >> "%WORKDIR%\SFTP_today.txt"

REM create zip folder zipFileName | folderName
ECHO zip -r D:\Reports\todayArchive.zip D:\Reports\Today >> "%WORKDIR%\SFTP_zip.txt"

REM transfer zip file
ECHO put *.zip>> "%WORKDIR%\SFTP_today.txt"

REM exit
ECHO bye >> "%WORKDIR%\SFTP_today.txt"

REM run script
"%WORKDIR%\winscp.com" /script="%WORKDIR%\SFTP_today.txt"
Guest




Fixed. Needed to use 7zip and perform the compression before the transfer.


"C:\Program Files\7-Zip\7z.exe" a -r %BackupFile% D:\Report\Today
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License