Comparing Excel with file info

how can I compare some photos in some folders and excel sheet has some paths of these photos so i want to which of these photos is not in the Excel sheet and copy it from this folder to another

Hi @omar_ismail

You can build a workflow like this

  1. Read the excel file and store it in a datatable by using Read Range workbook.
  2. Use the for each file in folder to iterate the each file in the folder.
  3. Use the for each row in datatable activity to iterate the every row in the datatable.
  4. Take an IF condition activity to check the condition

CurrentFile.Name.toString.contains("Currentrow(“Column name of path”).toString
leave the then block, In else block use the Move file activity to move the file from the current folder to another folder. Check the below workflow for better understanding.

Hope it helps!!

@omar_ismail

  1. Read Excel file and save in DataTable DT1
  2. Get Files list in String Array in assign activity
StringArray=Directory.GetFiles(folderPath)
  1. use for each loop over StringArray where files path are store.
  2. put assign activity
    FileName=Path.FileNameWithouExtension(FilePath)
  3. After Assign put If Condition
    put Condition
DT.AsEnumerable().Any(Function(row) row.Field(Of DataType)("YourColumnName").ToString().Contains(FileName))

  1. in then block put Move File activity and give File path and new path

@omar_ismail
it is the solution which you can solve in only one loop.
Happy automation


someting wrong

StringArray=Directory.GetFiles(folderPath)

I have more than one folder and subfolder so I can’t place someting instead of the (folderPath) in your expression

Hi @omar_ismail
Give like this
Place closed bracket at last

CurrentFile.Name.ToString.Contains(Currentrow(“Photo Path”).toString)

Regards,

what should i place in the copy (or move) activity in from field?

@omar_ismail
If you want to copy file from this folder to another then
In From field give as

CurrentFile.ToString

In To field give your destination folder where you want to save the file

The last thing I have an issue with and it will be perfect if u could assist

as you know the photos are in multiple folders and subfolders and I need to copy these photos to another place with the same sequence of folders and subfolders

E.X: I have two photos in folder one and inside it subfolder one
and I have 3 photos in folder two subfolders two

so I need to copy the photos from account one subfolder one to account one to subfolder one and so on

Hi @omar_ismail

Give the last .toString after the Photo Path close braces. Check the below expression for more clarification.

CurrentFile.Name.toString.Contains(CurrentRow(“Photo Path”).toString)

Give like this.

sorry but on which activity i should use this as it’s confusing me sorry again for bothering you

@omar_ismail

One thing you can do is…first copy all files to the folder or just copy the folder and rename it…using copy folder activity…and then rename…

Then loop theough the excel file and delete all the files that are present in excel file using delete file from the new folder

Cheers