Automatically compress files before download

Following script compresses selected files into tar/gzip archive and downloads it:

open mysession
cd %1%
call tar -czf /tmp/archive.tar.gz %2%
lpwd
get -delete /tmp/archive.tar.gz
exit

Launch the above script from batch file like the one below, which automatically decompresses the archive:

winscp.com /script=example.txt /parameter // %*
if %ERRORLEVEL% neq 0 goto error
 
echo Retrieving files succeeded
gzip -d archive.tar.gz
tar -xf archive.tar
del archive.tar
exit /b 0
 
:error
echo Retrieving files failed
exit /b 1

Example of running the batch file to download all files under /home/user/www:

example.bat /home/user/www *.*

The batch file needs Windows ports of gzip and tar tools. You can get them from UnxUtils project.

Further Reading

Advertisements:
 
  script_auto_compress_download.txt · Last modified: by martin
 

Search Documentation

This page

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

Associations

Site design by Black Gate