Search code examples
automationrpaautomationanywhereg1ant

How to find any "txt" file at particular location in system?


I have a robot to find a file of the given name at a particular location in a system but now I want to find all the text files at that particular location. I have tried to use "*.txt", but it didn't worked out. Is there a way to do that?

file.exists ♥environment⟦USERPROFILE⟧\Documents\t.txt errormessage ‴Sorry, I could not find a file‴
dialog ‴File exists‴

Solution

  • You can use the directory command. The pattern arguments allows you to filter out files of a particular extension.

    directory path ♥environment⟦USERPROFILE⟧\Desktop pattern *.txt result ♥files
    dialog ♥files⟦count⟧
    

    The above code should let you know how many files of the given extension exist in the given directory.

    You could take values from the returned list and use it with file.exists command.