How to read a text files with today's date in folder

Hi all,

Can you all please how to a read text file which has today’s date only and not other files which gets added everyday. how to write an expression so that it can open , files according to date.

I have tried writing it like this but its not working. Please do help me out

Thanks in advance :slight_smile:

@Bhavya_Amala_Kosana - could you please show the screenshot of the file name ?

Please check this post …

Did u mean u need to open the file having today’s date as creation date or file having today’s date as filename ?

file having today’s date as filename

Hi @Bhavya_Amala_Kosana

Can you please give a example name of the text file. So that we can design the code.

Thanks.

the file name is as follows cadence_18032021, cadence_19032021, cadence_20032021. i want my code to open and read only the file with today’s date

Hi @Bhavya_Amala_Kosana - please try like this

StrFiles = Directory.GetFiles(“yourpath”,“cadence_”+Now.date.ToString(“ddMMyyyy”)+"*.txt")

1 Like

Please find the below screen shots for your reference.

Feel free to reach us at any time if you have doubts. Thanks.

Happy Automation

Hi @Bhavya_Amala_Kosana

The best way would we to filter the files in the folder by the given condition and then read the list of text files which satisfies that

Check this workflowTesttn.zip (50.4 KB)

Hope it helps you

Regards,

Nived N
Happy Automation

It should be array of files. If there is only one file name for day then it should look like this:

StrFiles = Directory.GetFiles(“yourpath”,“cadence_”+Now.date.ToString(“ddMMyyyy”)+"*.txt")(0).toString

If there is more files with today date then 1:

arr_strFiles = Directory.GetFiles(“yourpath”,“cadence_”+Now.date.ToString(“ddMMyyyy”)+"*.txt")

And in for each item in arr_strFiles we can open the file :slight_smile:

1 Like

Thank you :slight_smile:

Thank you all for helping me. I got it. :slight_smile:

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