Author: Swaminathan Ramakrishnan
In this blog, we will be learning how to compress multiple files in a folder and move the file to specific folders in the compressed zip file.
In the below screenshot Archive is the source folder to be compressed in which all the files should be moved to different folders depending on the file type.
Add the compression module from exchange (In mule palette-> search in exchange-> search for keyword “compression” -> Add-> Finish).
Below is the anypoint studio code, which lists all the files in the archive folder. Compress and write the file E:\Archive\ZippedFile.zip
The dwl code snippet below moves the file types:
- “.jpeg” to images/jpeg
- “.jfif” to images/jfif
- “.csv” to docs/csv
And other file types will be placed in the root directory.
Below is the root folder of the zipped file:
Below screenshots show the location of the image files and the csv files respectively:
The above example shows how to use a compression module for compressing multiple files and changing the folder structures of the files in the compressed file.