Automatically zip folder before SFTP transfer
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"
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"