How to zip multiple result files ?

Hi,

I have a protocol which produce many output files (*.png,csv...)
I was wondering if there was a way to obtain only one zip file. I'd would be much easier for the user to download and unzip one file instead of 200.
I think it is possible but I didn't it in the documentation.

Thanks a lot.
Answers 6
GM
GM 2010-04-20
You'll need to run a command line compression utility with a Run Program (on Sever) component.
Windows Server 2003 doesn't have a command line zip utility (other than compress.exe, which is included in the resource kit but lacks the functionality you desire), so you'll need to install a 3rd party tool such as open source 7-Zip.

With 7-zip installed on the PP server do the following:
Write the files to that you want to zip to a temp location, e.g. $(TempDir)\resultFiles
Add a 'Run Program (on Server)' component under the pipe that writes the result files.
In the commandline parameter of the protocol enter the 7-zip command, for example:
"C:\Program Files\7-Zip\7z" a -tzip $(jobdir)\Results.zip $(TempDir)\resultFiles\*.*


Griffin
HP
HP 2010-04-20
Hi,

Thank you very much for your reply. It works perfectly.
I use a linux server, so I use the following command line :

zip -r $(jobdir)\Results.zip $(TempDir)\resultFiles\*.*

However the zip contains the entire path of the files. I mean, the whole arborescence is zipped. It appears like this in the zip file :

/opt/runtime/PipelinePilot/web/jobs/{wpt1A5EE-711F-1684-92A3-F02CC51D5AF9}/report/file.txt etc...

Is there a way to change that ?
Thanks.
HP
HP 2010-04-21
You can create a script which contains a cd command so that it runs from the $(jobdir) and can use relative instead of absolute paths. The attached protocol shows how to do this in Windows, on Linux it will be very similar but you probably need to make you script executable with "chmod u+x command_script".

Willem van Hoorn
comment imagecomment image
HP
HP 2010-04-21
quote:
runs from the $(jobdir) and can use relative instead of absolute paths. The attached protocol shows how to do this in Windows, on Linux it will be very similar but you probably need to make you script executable with "chmod u+x command_script".


Indeed, : cd $(jobdir) && zip -r Results.zip resultFiles\*.*

works very well

Thank you for your help.
SR
SR 2010-04-23
A similar request came up from some customers recently. I created two components based on the Dynamic Java Component (on Server) component, so that they would be platform independent.

The Decompressor component simply decompresses the contents of a file (either Zip or GZ)to a specified folder.

Here's part of the help from the Compressor component:

The component can be used to compress the contents of a given folder or a list of files into a single Zip file.

Compress a Folder
In this mode, the contents of the folder specified by SourceFolder will be compressed into a single Zip file specified by Destination. The specified folder will be recursively traversed into order to get everything in that folder structure. If any file in that structure can't be read, then an exception will be thrown.

Compress Files
In this mode, files will be collected from the data stream and compressed into a single Zip file specified by Destination. The property on the data stream which contains the file names is given by FileProperty. If any file can't be read, then an exception will be thrown.
comment imagecomment image
HP
HP 2011-01-17

Hi Srieth

Great protocol for file decompression! Thanks alot.

Was just wondering though, would it be possible to decompress multiple files? I was able to select multiple .gz files in the CompressedFile field but there was an error (Compressed file does not exist:...) when the protocol ran midway.

I am aware that there is a decompress property component under the Chemistry collection. However, I'm not too sure if I could use this for general file decompression too? I've tried using a File reader to read the .gz file and then use the decompress property but there was an error. So I'm not too sure how to go about in decompressing multiple files.

Does anyone have any ideas?

Appreciate your advises.

Thank you!

Liz