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%
get -delete /tmp/archive.tar.gz


Launch the above script from batch file like the one below, which automatically decompresses the archive: /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
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


Last modified: by martin