I am looking to delete a file form a folder but dont want to delete all the files in the folder.
Basically the file will be open by UiPath and run through the process on the server which at the end of the process i will need UiPath to pick up a specific name of file to delete.
Hi
Hope these steps would help you resolve this
—use a assign activity like this arr_filepath = Directory.GetFiles(“yourfolderpath”,”Invoice.csv”)
Where arr_filepath is a variable of type array of string
—now pass this variable as input to for each activity and change the type argument as string in the property panel of for each loop activity
—inside the loop use a DELETE activity and mention the file path as item.ToString
—this will all the files with csv file type and having invoice as a word in its Filename
the file thats saved on the server doesn’t have ‘Invoice’ written in it however it will have invoice written in the file itself.
i was thinking if i used get ocr text to find the text ‘Invoice’, then move on to a IF statement if the condition is true to delete the file if its false to leave the file where it is.
would this work?
The file wouldn’t need to be opened as on the server once you click on the file there is a preview screen where you can see if the word ‘Invoice’ is present.
But didnt you say the process will open the file? How do you know which one you will open? If you need to open several files, to see if invoice word is inside, use read text file not ocr…
no the process won’t open the file however it will go to the location of the file, i know of a few file names that i need to delete which is fine i can do that with click activity. However i have other files there which if they have the word Invoice in them i would need to delete.
I also don’t know how many files will be located there on some days it will be 10 other days 3 therefore need to add a loop into the process until all the files have been checked.
oh ok understood, then if your application dont have a built in file viewer, you may need to download each one and search for the string inside to be able to find the one to delete…
being a preview, does that mean that you cant see the whole text and might not be able to identify the word Invoice? If yes, then maybe a simple image activity might do the trick…