Zipping multiple files into 1

I’m using the Compress/Zip Files activity and understand that if I wish to zip multiple files I have to seperate each file full path by “|”. I’ve tested the activity but the zip always gets corrupted and return the following error.

Cannot extract data from archive “C:\RPA\Billing\Downloaded\SR-230816-0002.zip”.

The zip file does get created successfully but just couldn’t be opened. The variable holding the file name returns the following.

C:\RPA\Billing\Downloaded\SR-230816-0002 - MOH-FY19-000296.pdf|C:\RPA\Billing\Downloaded\SR-230816-0002 - MOH-FY19-000297.pdf

Any and all advise appreciated. Thank you.

Hi @QTH

Use an array or list: Instead of concatenating file paths with “|”, consider using an array or a list to hold the file paths. This can help you avoid any issues related to formatting or special characters.

Assign FilesArray = {"C:\RPA\Billing\Downloaded\SR-230816-0002 - MOH-FY19-000296.pdf", "C:\RPA\Billing\Downloaded\SR-230816-0002 - MOH-FY19-000297.pdf"}

Then, you can pass the FilesArray variable to the Compress/Zip Files activity.

Hope this helps!!

Could you advise how to use the array? The Compress/Zip Files activity expect a string value so the array doesn’t work.

@QTH

You can try this way also

image

The number of files and names are dynamic hence I had to use a variable to store the path. Is there no other way?

It’s fine that you have file names with pipeline

Use a assign activity like this to get the array of filepaths like this

arr_filepaths = Split(yourvariable, “|”)

where arr_filepaths is a variable of type array of string

Now use a FOR EACH activity and pass the above array variable as input and change the type argument as string

Inside the loop use a COMPRESS TO ZIP activity and pass the filepath to be compressed as item.ToString and mention the zip folder path where u want to keep it compressed with its name

Hope this helps

Cheers @QTH