How to move pdf files from multiple folders having DDMMYYYY format and copy to new location

Hi team,
I am working on a scenario in which I have to classify the documents placed in shared location. I want to develop a workflow that opens that specific shared folder and the open the year 2021 folder, in which there are subfolders having DDMMYYYY name format i.e. 01 august 2021. I want to open DDMMYYY folder and classify the required documents out of a documents pool. And then placed the classified documents to the specific folder. I have to repeat the same process for multiple folders having the DDMMYYYYY format.

I have already classified the documents paced in one folder by get.Directory method. But I am confuse with the folders and subfolder scenario.

Any help in this regard will be highly appreciated.
Thank You.

Regards

Enthusiastic

I am not clear with your requirement. 01 august 2021 is dd MMMM yyyy format not DDMMYYYY format. So if you could share some screenshot of your folder structure we can take a look and assist you.

2 Likes

Hi @enthusiastic

If you’re stuck on getting files within subfolders, use the SearchOption parameter in Directory.GetFiles method to read all files including those in subfolders.

Directory.GetFiles(YourTargetDirectory, "*", SearchOption.AllDirectories)

Aside from that, I agree with @prasath17 - can you please give more details and include screenshots?

1 Like

@enthusiastic - Thanks for sharing the screenshot.

“I want to open DDMMYYY folder and classify the required documents out of a documents pool. And then placed the classified documents to the specific folder.” - Now please clarify this point.

If you would like each folder under the 2021 folder…Below code will first get you inside 2021 folder…

Directory.GetDirectories("ParentFolderPath\"+now.year.ToString,"*",SearchOption.AllDirectories)

Once you are inside 2021 folder…then you can loop each files under the folder as shown below…

Hope this helps…

1 Like

will let u know after executing it.

This is exactly I was asking from the beginning.

1 Like

@enthusiastic - See my input folders…

image

If loop code:

system.Text.RegularExpressions.Regex.IsMatch(Eachfolder,"\d+\s\w+\s"+now.year.ToString)

You can see Only 4 times it went inside the loop “Inside Then==>”

1 Like

Following the solution you have provided. I have reached in the folder 2021. There are many subfolders as the screenshot is attached. I get into the specific subfolders like I have mentioned above, and classify the documents by using classifier. After getting classified files from the specified subfolders I want to write the classified and unclassified files name and path to the excel sheet.
That’s the whole scenario…
I hope you have got my point.
Thank You
Regards

@enthusiastic - I guess our posts came at the same time. Please check the solution above, it might meet your expectation.

1 Like

I have implemented your model. It worked perfectly and get me the pdf files out of the directory.
I have one more question regarding the workflow…

Once I have entered in folder 2021 after that there are multiple folders like 1 JAN 2021, 3 Feb 2021 and so on. Once I have entered in the 1 Jan 2021 folder which is the first folder of the directory 2021, there are many subfolders in it. I want to fetch pdf files from the specific folder in the 1 JAN 2021 which is having naming convention like this 5555ABCD. After reaching this specific folder I want to put the classifier, and write those classified files to excel.

Any help in this regard will be highly appreciated…
Thank You

These folder names are dynamic right?? so how do you know the folder name upfront say 1 JAN 2021? Or do you want to fetach 5555ABCD files from every valid folder names??

Please share some sample screenshots to understand your problem better

1 Like

plz have a look on the screenshot.

The folders are placed in the 1 jan 2021 folder. The 1 jan 2021 folder is present inside 2021 folder.

The folders that are showing in the image contains multiple pdf and .jpg files.
I want to classify the 5555ABCD folder files. After classifying I want to move the classified files to any temp folder on the system.

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