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
- Read the excel file and store it in a datatable by using Read Range workbook.
- Use the for each file in folder to iterate the each file in the folder.
- Use the for each row in datatable activity to iterate the every row in the datatable.
- 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!!
- Read Excel file and save in DataTable DT1
- Get Files list in String Array in assign activity
StringArray=Directory.GetFiles(folderPath)
- use for each loop over StringArray where files path are store.
- put assign activity
FileName=Path.FileNameWithouExtension(FilePath)
- After Assign put If Condition
put Condition
DT.AsEnumerable().Any(Function(row) row.Field(Of DataType)("YourColumnName").ToString().Contains(FileName))
- 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
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
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