How to check if a file exist inside a folder and then get the filename for that specific file and move the file to another folder

Hi all,

Let me explain the situation:

I need to search for a file name in a folder where are many different files. For example a file like this:
“All Data Export_1_spend_3_2018” Find that specific file and than move that specific file to a different folder. The problem is that the file changes name every month AND every year (when I download the file): For April will be: All Data Export_1_spend_4_2018. If we are in 2019 will be
“All Data Export_1_spend_3_2019”.

Can somebody please help with this?

Thank you

3 Likes

Hi @Prog,

You can check using if condition
path.Exists("full path")

True-> file exists.
False-> file not exists

Move file activity to move the file from one folder to another folder

6 Likes

Few file search patterns:

Current Month

String file=Directory.GetFiles("filepath",“All Data Export_1_spend_"+now.Month.ToString+"_"+now.Year.ToString+".xlsx").First

All 2018

Array Files= Directory.GetFiles("filepath",“All Data Export_1_spend_*_"+now.Year.ToString+".xlsx")

3 Likes

Thank you very helpful!!

Hi, I have the same issue.

BUT, my file name includes time_stamp as well.

How can I resolve this issue?