Unzip several files in several folders

Hi, I have a folder with several subfolders, each subfolder has zip files, I am trying to unzip each file that is in each subfolder but it has not been possible.

I mean, I need it to enter each folder and if there are zip files then unzip them and so on with all the folders.

Hi @manuel.rojas,

Have you had a chance to try this?

Directory.GetFiles("your file path","*.zip", SearchOption.AllDirectories)

Regards,
MY

1 Like

I currently have this

I did this to test that with many zip files in a single folder and yes, they all unzip, however I have zip files in many folders and not just one.

1- First, fix the equation as follows.

Directory.GetFiles("C:\Users\Juanr\Documents\UiPath\Factura_Electronica\Archivos correo\Prueba","*.zip",SearchOption.AllDirectories)

2- Update your variable type to String.String.

When you update these fields, the for loop will return it as an array list.

Each item in the loop becomes a zip file and this folder will bring you all the zip files in that directory in order.

The “typeArgument” of the for each is “System.IO.FileInfo” this way I get the “extract” activity to allow me to use “item.FullName” and “item.DirectoryName” as shown in the image, then if I change the “TypeArgument” it will show me an error.

What should you do?

You can use your uipath activity. You don’t need to go to an external activity. It comes when you type extract. I am sharing how to use it below.

1- Directory.GetFiles("C:\Users\Juanr\Documents\UiPath\Factura_Electronica\Archivos correo\Prueba"," *.zip",SearchOption.AllDirectories)`

2-String.String

3-"extract folder path"

Path.GetFileName(item.ToString)

image

The folders (purple color) have zip files which are unzipped in folders (green color) but as you can notice they are unzipped outside their place of origin, I need them to be stored inside the same folders (purple color).

Hi @manuel.rojas,

Sorry for the late return.If you update the destination field like this, it will extract every zip folder to the file containing the zip.

item.Replace(Path.GetFileName(item.ToString),"")

Regards,
MY

1 Like

@manuel.rojas Give a try with the below attached code

Example.zip (4.3 KB)

Code

Input

Input1
Input2

Output
Capture
Capture1

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.