Check file in path with specific format name

Hi, Everyone
How to check file in path has format “XXX_YYYYMMDD_Report.xls”
In my loop checking

File as string{}
File = Directory.GetFiles(“PathFile”,“*_Report.xls”, SearchOption.AllDirectories)

PathFile has
bbb_20210312_Report.xls
aaa_20210313_Report.xls
ccc_20210314_Report.xls
yyy_12345678_Report.xls —> I don’t want this file.

Can I check pattern “YYYYMMDD” in file name? Please suggest.

Thank you in advance.

Hi Supakinee_Navawong_na_ayu,

Based on my knowledge i am providing suggestion below. just check if it is useful to you.

i think we cannot directly give YYYYMMDD in search criteria.

you are checking all the files with the format of YYYYMMDD right. try to get the current year and current month dynamically from the functions like Current Year - now.toString(“YYYY”).tostring and current Month - Now.tostring(“MM”).tostring. and pass it to your search criteria like below.

ile = Directory.GetFiles(“PathFile”,CurrentYear+CurrentMonth+“*_Report.xls”, SearchOption.AllDirectories) some thing like this it should work and take correct files and ignore the rest of ones.

Regards,
Kiran.

Hi @Supakinee_Navawong_na_ayu ,

Please check the Date Examples section from our colleague megapost https://forum.uipath.com/t/regex-help-tutorial-megapost-making-your-first-regex-post-reusable-regex-patterns-regex-troubleshooting-sample-workflow-and-more/238791

Might help you, not only for this issue :slight_smile:

Best regards,
Marius

2 Likes

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