Compare two different zipfile and check if the text file was only existed in one file?

Need help!

I need to compare two different folders and check if the text file was only existed in one folder?

Note: I have two different zip files “beforeExample” and “afterExample”, I need to check two zip files if they have both files named correlation_order.txt. If not refer then print the expected result

Expected Result:

correlation_order.txt
This file only exists in afterExample.zip

I would follow these steps:

  1. Unzip the files (Check this video :point_right:t2: In UiPath, How Do I Unzip or Extract a File? - YouTube)
  2. Check the contents inside the unzipped folder
  3. Compare the texts
  4. Take necessary action

Hi, @fniedez

See if the attach workflow works for you

Basically, We retrieve all name files from both zip files using Invoke PowerShell (it doenst necessary unzip files)

The output of two Invoke PowerShell is a collection of string for ZIP A and ZIP B. After we look up if the collections has correlation_order.txt file.

Remember to change ZIP A and ZIP B path into parameter in Invoke PowerShell Activity:

_Test.xaml (12.5 KB)

Hello @rikulsilva

I can’t open your file

Can you please take a screenshot of your workflow?

Thanks,
France

Hello @fniedez

I have a attached .xaml file for unzip the folder.


in above the image you can see Inputfile and Expath in Arguments which is Input path of zip folder and folder where the files need to be extracted and Extractpath is Final path of zip files which is extracted.

After that you can find the text by using Path exist or Get Directory method.
unzip.xaml (7.5 KB)

Please check and let me know the feedback from you

Have a great day :wink:

Hi

Which Studio version are you using?

I have attached the same workflow but in 21.10 version. Let me know if it works for you

CompareZipFiles.zip (2.8 KB)

Hi @fniedez

You try this method to get the files inside the zip folder

Then you need to use this method to get the list from the both the folders and you can check for the file is existing in the both the folders and continue your next steps

Regards
Sudharsan

Hello @rikulsilva

This is the version of my UiPath Studio, kindly check the picture:

Pardon, I can’t open your workflow file.

Thanks,
France

Hi
I will update with screenshot of the flow

Hello @rikulsilva

Please, kindly inform me once you are done.

Thanks,
France

Hi, @fniedez

Workflow image:

Invoke PowerShell:

"
param ($path)
[IO.Compression.ZipFile]::OpenRead($path).Entries.FullName
"
image

Invoke PowerShell properties:

image

Invoke PowerShell parameters:

ELSE IF EXPRESSIONS:

FIles_ZIP_A.Any(Function(x) x.ToUpper.Trim.Equals(“CORRELATION_ORDER.TXT”)) and FIles_ZIP_B.Any(Function(x) x.ToUpper.Trim.Equals(“CORRELATION_ORDER.TXT”))

Both ZIP Files has the ORRELATION_ORDER.TXT

Else IF

FIles_ZIP_A.Any(Function(x) x.ToUpper.Trim.Equals(“CORRELATION_ORDER.TXT”))

Only ZIP A has the ORRELATION_ORDER.TXT

Else IF

FIles_ZIP_B.Any(Function(x) x.ToUpper.Trim.Equals(“CORRELATION_ORDER.TXT”))

Only ZIP B has the ORRELATION_ORDER.TXT

1 Like

Hello @scott_zielinski

  1. How can I define if all the files are the same exist in two different files? The output will be TRUE or FALSE

  2. And how can I check two different extracted files if they have the same filename/textfile? This is the name of the text file correlation_order.txt so the output will be:

     The output in this step will be like this:
       correlation_order.txt
       This file only exists in afterExample.zip
    

Hello @rikulsilva

Sorry for late reply, it works but you definitely you put the correlation_data.txt as literal string. It is possible if you can check first all the possible text file in two different files. Then if the Before files have not filename correlation_data .txt therefore it can find it on the After file. Then the output is the same.

Note: do not put correlation_data.txt as literal string you need to determine if Before and After have correlation_data.txt and if not then print the expected output.

Thanks,
France

Hi
I don’t get it.

Do you need check all txt files ?

The correlation_data.txt is it dynamic name ?

The code provide just check if zip has correlation_data.txt not matter the other txt files.

Sorry - I was mistaken in my post.

dont worry

Do you were able to solve your problem?

Hello @rikulsilva ,

Sorry for late reply, it didn’t solve the problem. I’ll give you a scenario.

Scenario:

  1. Extract two different zip files (before and after).

  2. Check all the config files and their names inside of the Before files then you need to compare all the files of before in After files if there are the same name.

  3. Check the Before files again if has a correlation_data.txt then compare it to After files if after file has only a correlation_data.txt,

    then the expected output:

    *  correlation_order.txt
         This file only exists in afterExample.zip
    

    Note: In this 3rd part do not print literal or insert as a string of the name “correlation_data.txt” the flow will be automatically look the text file in two different folders.

  4. Compare the data of all config files inside of the Before Files to After Files. Then the expected output:

    filter_message.cfg
    before_change(Line:1): #test1
    after_change(Line:0):
    
    filter_time.cfg
    before_change(Line:6): #test2
    after_change(Line:6): #test3
    

Hello @rikulsilva ,

I already send a message to you, kindly check it.

Thanks,
France