Check if several files with different name are ready, and then move each of them to destination folder

Hi All,

I’m working on a automation process that to check if several files are ready in different original path, and then move them to a destination folder once ready.

For example, I have 15 files on hand and need to check if each of them is available in different path:
AAA.xlsx stored in C/XXX/202008
BBB.xls stored in C/YYY/202008 and so on so forth

My question is how to check all these files and move them to a specific location once existed?
I just know how to check a specific one file but no idea how to deal with tons of files.

Many thx

Hi,

You can Search the MainFolder C with search All directories file. This will get all files in all Sub folders.

string[] allfiles = Directory.GetFiles("Main Folder", "*.*", SearchOption.AllDirectories)

Thank you for you prompt answer. but after I get all files from Main folder, how can I get those 15 specific files

Can you explain how you are Finding 15 files?
If based on 202008 then the Files in array can be Filtered based on name.

it’s actually based on its specific name convention. Basically, it’s a monthly checking, like every month, I will receive several files from different department. So all file have different prefix and name, e.g. AAA 202008, BBB 202008, 202008 CCC,20200830 DDD. As the date indicated in different place for each file, I will store all file name with formula in an Excel, and then just get all file name from that Excel.