Ignore file if it does not exist on DataTable

So I have the following scenario:

A folder with 50 files
An excel file with 12 rows
(this values changes every time)

I need a robot to do the following:

Grab the name on Excel row and search for file(s) that starts with that name on the folder
Move the file to another folder
Get the row if it doesn’t have a file associated and store it on a DT or array

So far I only manage to move the files properly, but I can’t find a way to check if the file exists or not so I can store the name of it on a DT or array :confused:

Hi @cteixeira !
To check if a file or a folder exist, you can use path exists activity: it will return a boolean (True if it exists, otherwise False)

But that way if it doesn’t found a file (let’s say on the 1st or 2nd row) but the file it’s on the 10th row, it will throw as false even if the file it’s there
And the DataTables doesn’t have the files extention to check if the files exist or not

No don’t worry :grin:
First once you get the excel file name in your datatable, use immediately a Path Exists on your folder; path exists will see all of your files in the given folder.
So if path exists say that the file does not exist, then you can move if to the error folder, otherwise it will go to the success folder.
Do you mind sharing your workflow ? It will be easier to explain with it

1 Like

if the DT does not have all the files extension, we will try with a wildcard (I don’t know if it will work).
If the wildcard option does not work, we have an easier solution: use Directory.GetFiles().toList to get all the files in a list, and then check if the row is contained in the list

1 Like

Hi @cteixeira

Check this workflow

I had made a sample workflow where there are some files in source folder , and there is a input.xlsx file [Sheet1]

Bot will check the sheet1 of input.xlsx file and searches in source folder whether any filename starts with the value in row, if it , it then move the file into destination folder otherwise the row data will add to a datarow and then is finally wriiten to a excel file.

Check this workflow
Testtn.zip (47.1 KB)

Test with your data too and let me know if it is fine for you


Nived N

Happy Automation


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