# Compress files
Compress files is one of the actions under
Files by Workato application. It allows you to compress multiple files into one .zip file. The source files can come from any app (e.g. Amazon S3, Dropbox, Salesforce, etc.)
# Example: Compress all files in a folder
In this section, we will go through one example of how to compress all files in a folder.
We will use an SFTP folder for this example. However you can use this same method with any other app like Amazon S3, Box, Dropbox, Salesforce, etc.
You can find the sample recipe here.
The recipe may look a bit daunting at first, but once you get the idea it is actually quite straightforward. Let's go through the thought process step by step:
We have a folder in SFTP with several files. We need to compress all files in that folder into one .zip file.
Compress filesaction, we see that it needs a list of
- To get
File contentsof every file in the folder, follow these steps:
- List all items in the folder (including both files & sub-folders):
- Now we will go through each item one by one. To do this, we use a "For each" step (a.k.a. Repeat Step):
- First we need to make sure this item is a file and not a folder:
- If it's a file, then get the
- Now we will save
File contentsinto a list. The first file in the folder (index = 0) will be saved into
- Repeat this step for the rest of the files. In this example, there are 3 files in total. We save them into 3 lists:
- Now we are ready to use
Compress filesaction. From the App data box, drag & drop
File contentspills from the 3 lists into
- The last step is uploading the zip file to the destination
- Putting everything together, we have the complete recipe: