How to create a UiPath workflow that extracts file names stored in a data table column that do not exist in a particular folder. I want to check this for a set of folders in one loop and get folder wise log output.
Folder A = 2 files - qq.xyz,ww.xyz
Folder B = 4 files - kk.xyz,dd.xyz,kk.xyz,rr.xyz
File names in data table= qq.xyz,ww.xyz,kk.xyz,dd.xyz,kk.xyz,rr.xyz,jj.xyz,vv.xyz,tt.xyz,pp.xyz
Below is a UiPath workflow that extracts file names from a DataTable and checks if they do not exist in a folder. This workflow assumes you have a DataTable containing file names in one of its columns.
Drag and drop a “For Each Row” activity onto the workflow canvas.
Set the DataTable you want to loop through in the “For Each Row” activity.
Inside the loop, add an “Assign” activity to get the file name from the current row of the DataTable. Let’s assume the column containing file names is named “FileName”. You can change this according to your DataTable structure.
In the “To” field, add a new string variable, say “currentFileName”.
In the “Value” field, use the expression row("FileName").ToString().
Add an “If” activity inside the loop to check if the file exists in the folder. You can use the System.IO.File.Exists() method to check if the file exists.
Condition: Not System.IO.File.Exists(Path.Combine(folderPath, currentFileName)). Here, folderPath is the path to the folder where you want to check for the file.
If the file does not exist, you can add an activity to perform any action you want, like logging the file name or performing some other operation.
3.1 For Each (row in data_table)
- If (filesInFolder.Contains(row(“FileName”).ToString))
- Log Message: "File exists: " + row(“FileName”).ToString
- Else
- Log Message: "File does not exist: " + row(“FileName”).ToString
- End If