Get Folders Action - with certain conditions
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
16-03-22 12:35 PM
Hello,
I'm looking for an option to get all folders created before/after certain DateTime Or only get X number of folders based on ascending descending order. Kind of direct filter before we get collection.
I have a target folder containing appx 1lac files and my first step is to get all this in a collection and then filter only required files for further operation.
My concern is System.OutOfMemory exception if this scenario goes to production.
Those 1 lac files will be there in target folder due to other tool dependency and it can grow in future. Meaning we have no solid control of archiving or deleting due to certain dependency.
I'm using Get Folders action as of now from Utility-File Management VBO.
So looking for some workaround or alternative.
------------------------------
Thanks & Regards,
Tejaskumar Darji
Sr. RPA Consultant-Automation Developer
------------------------------
I'm looking for an option to get all folders created before/after certain DateTime Or only get X number of folders based on ascending descending order. Kind of direct filter before we get collection.
I have a target folder containing appx 1lac files and my first step is to get all this in a collection and then filter only required files for further operation.
My concern is System.OutOfMemory exception if this scenario goes to production.
Those 1 lac files will be there in target folder due to other tool dependency and it can grow in future. Meaning we have no solid control of archiving or deleting due to certain dependency.
I'm using Get Folders action as of now from Utility-File Management VBO.
So looking for some workaround or alternative.
------------------------------
Thanks & Regards,
Tejaskumar Darji
Sr. RPA Consultant-Automation Developer
------------------------------
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
17-03-22 06:15 AM
Hi @Tejaskumar_Darji
I duplicate and change little bit the "Get Folder" action to create "Get Folder - Filter" action in the "Utility-File Management" VBO.
Find attached to this post.
For use it. Only need to put the two dates that you want to filter.

I try it and works pretty good.
Hope this helps you!
See you in the community, bye 🙂
------------------------------
Pablo Sarabia
Architect
Altamira Assets Management
Madrid
------------------------------
I duplicate and change little bit the "Get Folder" action to create "Get Folder - Filter" action in the "Utility-File Management" VBO.
Find attached to this post.
For use it. Only need to put the two dates that you want to filter.
I try it and works pretty good.
Hope this helps you!
See you in the community, bye 🙂
------------------------------
Pablo Sarabia
Architect
Altamira Assets Management
Madrid
------------------------------
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
17-03-22 06:17 AM
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
17-03-22 07:08 AM
Hi Tejas,
Not sure if this will be able to solve the issue as I didn't test the same with 1 lac folders 😛
But well, you can give it a shot as I am using LINQ queries with Folder Retrieval as a part of the below custom code stage. I am using LINQ queries as it can speed up your collection filtering by miles.
You can create a new business object and add the below External References ('System.Data.DataSetExtensions.dll', 'System.Core.dll') and Namespace Imports ('System.Data.DataSetExtensions', 'System.LINQ', 'System.IO' and 'System.Collections.Generic') on the Page Description stage of your Initialize action for the LINQ queries to work properly. Also, ensure that the language is selected as 'Visual Basic':

Once you have the updated code options as shown above, create a new action named 'Get Folders By Filters' and pass three input arguments, Folder Path (Text) and Start Date (Date) and End Date (Date). Based on the field names that you provide the unique records will be fetched from the Input Collection. Also, set an Output parameter as Folders (Collection) for this action as shown below:

Add the code stage and use the below code with the input and out arguments as show:

The run results are as follows:
Input Arguments:

Output Result:

------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future
Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
Wonderbotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com
----------------------------------
------------------------------
Not sure if this will be able to solve the issue as I didn't test the same with 1 lac folders 😛
But well, you can give it a shot as I am using LINQ queries with Folder Retrieval as a part of the below custom code stage. I am using LINQ queries as it can speed up your collection filtering by miles.
You can create a new business object and add the below External References ('System.Data.DataSetExtensions.dll', 'System.Core.dll') and Namespace Imports ('System.Data.DataSetExtensions', 'System.LINQ', 'System.IO' and 'System.Collections.Generic') on the Page Description stage of your Initialize action for the LINQ queries to work properly. Also, ensure that the language is selected as 'Visual Basic':
Once you have the updated code options as shown above, create a new action named 'Get Folders By Filters' and pass three input arguments, Folder Path (Text) and Start Date (Date) and End Date (Date). Based on the field names that you provide the unique records will be fetched from the Input Collection. Also, set an Output parameter as Folders (Collection) for this action as shown below:
Add the code stage and use the below code with the input and out arguments as show:
Dim folderDir As New DirectoryInfo(Folder_Path)
Dim folder_enum = (From folder In folderDir.GetDirectories() _
Where folder.LastWriteTimeUtc.Date >= Start_date And folder.LastWriteTimeUtc.Date <= End_Date _
Select New With {.FolderName = folder.Name, .Path = folder.FullName, .Created = folder.CreationTimeUtc, .LastAccessed = folder.LastAccessTimeUtc, _
.LastWritten = folder.LastWriteTimeUtc})
Dim dt As New DataTable
dt.Columns.Add("Folder Name")
dt.Columns.Add("Path")
dt.Columns.Add("Created")
dt.Columns.Add("Last Accessed")
dt.Columns.Add("Last Written")
Dim dr As DataRow
For Each item In folder_enum
dr = dt.NewRow
dr("Folder Name") = item.FolderName
dr("Path") = item.Path
dr("Created") = item.Created
dr("Last Accessed") = item.LastAccessed
dr("Last Written") = item.LastWritten
dt.Rows.Add(dr)
Next
Folders = dt
The run results are as follows:
Input Arguments:
Output Result:
------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future
Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
Wonderbotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com
----------------------------------
------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.
