Question about File Found with List Directory Files

Hi!

I am trying to build a process that checks to see if a file with a specific extension exists inside a directory. I have a process that looks for that already; however, I cannot seem to figure out the step to either proceed with the process if the specific file exists or send an email and stop the process if there is no file in the directory. This is what I have to find the specific file:

This is one of the many types of logic I tried using in the File found? activity:

image

When there is a file in the directory, it saves the file name and extension to the variable, ri_submission_files–for example, [“RI_11_28_2022_11_28_2022_638052259226240994.xlsx”]. However, when there is no file, it only shows .

Edit: As of now, I’ve tried using ri_submission_files.includes(“.xlsx”) as well as !ri_submission_files.includes(“.xlsx”)

Thank you in advance for any guidance you can provide!

I figured out the solution by using the Basic Editor instead of the Advanced one.

I noticed that the variable would show [ ] if the file didn’t exist, so I just made it where the variable didn’t equal [ ].

1 Like

@BrandonTerry, the output of “List directory files” is a list. This is why you see [ ] when the directory is empty. So, these are two alternative options that I would suggest to deal with your case:

  1. If you know the full file name you can just use the “File found?” activity
  2. If you want to check if there is any file name with extension “.xlsx” you could do:

image

Because the variable is a list you first need to convert it to a String by using toString() before using the method includes().