How to pick folder based on year and month(yyyy_MM)

Hi

I have a folder say Report under which i will have two more folder say 2019_01 and 2018_12 .
Now, in these two folders have some processed report files present.
So, Firstly i have to check if current month folder is there or not ( say month and year is coming from “20-01-2019” after some manipulation) then, check if files are there or not in the present month folder but if no files are there in current month folder then look for the previous month folder if present . And over here again i need to check if files are there in previous month folder or not…

I am stuck over this place … can someone please help me on this.

Regards,
Ahtesham

@md.ahtesham

Get all directories from report folder.
Use for each to get single folder under reports
Now get all files from child folder and check child count is greater than 1
If child count is greater than 0 then retrive back parent folder name.

Give it a try…
I will provide sample code for same…
If you have some sort of folder structure please upload in zip format so that it will be easy for us to evaluate.

Regards,
Aditya

Please find the folder structure

I followed your part but i was not successful.

Adding more - there are chance that this Report folder can contain other subfolder but we are only concerned with picking present month folder and if no files are present then look for previous month folder. If even not found in previous month then throw business exception[ this exception part please ignore]

Please help…

Regards
Ahtesham
Report.zip (15.8 KB)

@md.ahtesham

is this you want?

folder_intration.xaml (8.5 KB)

regards,
Aditya

working? @md.ahtesham

@rahatadi
This does not answer to the requirements, as it looks for all the folders by the date of the creation, or it might fetch the folder from somewhere else or generate all the folders at once with some kind of reporting tool.

@md.ahtesham
check this:

  • I am taking the current date and a stepper
  • searching the folder named yyyy_mm (surround with try-catch, as the folder might not exist)
  • if the folder is found and it has files in it, I exit the loop and go to processing step
  • otherwise, I increase the stepper and repeat the steps with the values for the previous month

Main.xaml (10.0 KB)

2 Likes

@c.ciprian

i though that those are fixed folders under reports. like generated by some tools or something.

so i kept it simple

but thanks for suggestion…

Regards,
Aditya

@md.ahtesham till what loop should the process run? you can have yyyy_MM for as many times as you want.
when do you expect to exit the search loop for previous month folder?

In the flow I have provided, the stepper goes up 9 times, so at most 9 month back, but it can be simply changed.

L.E: Actually, rereading the request, the iteration should stop at one month back

@rahatadi
He mentioned there might be other subfolders in there

1 Like

Thanks a lot .

I have not gone through xaml files . I will go through it once I get some time. But @c.ciprian is understanding the scenario is correctly.

@nadim.warsi - At first bot will look for current month folder i.e 2019_01 and then check if file is inside or not …if Found then it will do the rest processing part but if either folder or files are not present then it will try to look for previous month folder(2018_12) and files inside it - if it is found then it will pick the file and do processing but if here also bot is not able to get file then I will throw business exception.

@nadim.warsi - when do you expect to exit the search loop for previous month folder? – I want to exit after previous month.

Regards,
Ahtesham

1 Like

then its fine. the solution already provided will work perfectly by adding some tweaks

@md.ahtesham , @c.ciprian

this is another way of doing same…and no need to specify when this process end :slight_smile:
it will find all folders which are in yyyy_MM format and check that contains some files or not.

suggestions are welcome.

folder_intration.xaml (11.1 KB)

regards,
Aditya

Hi
I have a mail folder say Inbox1 under which i will have number of subfolders say 01 - Jan, 01-Jan FM, 02 -Feb, 02 - Feb FM, and so on till 12 - Dec and 12 - Dec FM .
Now, in these 24 folders have some processed mails present.

So, I have to move mails of 3 month older month from current month to destination folders say Inbox2 and Inbox 3
Inbox 2 is the destination folder for 01 - Jan kind of folders , i.e., without suffix FM
Inbox 3 is the destination folder for 01 - Jan FM, i.e., with suffix FM

And the subfolders under inbox 2 and inbox needs to be created as per inbox 1 with month and year values.

I am stuck over this place … can someone please help me on this.
Regards,
Chandni