Hi all, I have x n o no files in one location. I need to check if date modified is equal to current date and if it is then I need to check for a certain type and if it that type’s available then get that file.
At present I have a for each loop over that directory and an if condition saying if date modified is same as current date then do stuff. The problem with this is since the for loop is there when the bot loops through the directory and if there are other files available whose modified date isn’t the same as today date it goes to the else section. I want the bot to look in the directory ,find the file whose last modified date is same as today’s date and then check for its type and perform actions on it. How can I do this. Please advise.
Use assign activity : getFiles =directory.GetFiles(FolderPath)*
FolderPath= Path of folder where your files are present
Use for each activity
Inside body of for each use if condition activity item.ToLower.Contains(“.pdf”)/item.ToLower.Contains(“.xlsx”)* etc.
if yes then proceed
Or you can use Path.GetExtension(GetFiles) to get the extensions
for checking DateTime modification = IO.File.GetLastWriteTime(“C:\test.txt”)
Change “C:\test.txt” to your filepath from for each
then check it in an if condition.
Hi @Shubham_Dutta, the issue with this is, if file type isn’t .pdf inside the for each, it will just go to the else section . I want it to move to the next item and check again until that file is found.
Hi @Anived_Mishra ,
With if else condition also you can proceed to next files inside a for each.
I am sending you a sample workflow which has sample files inside “Folders” for your reference. ReadFiles.zip (134.4 KB)