# Create dynamic array lists

**URL:** <https://forum.uipath.com/t/create-dynamic-array-lists/505200>\
**Category:** Studio\
**Tags:** array, variables-management, list, question, studio\
**Created:** [January 6, 2023, 9:25am UTC](https://forum.uipath.com/t/create-dynamic-array-lists/505200 "2023-01-06T09:25:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjamin.9052](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/benjamin.9052/32/177246_2.png) [@benjamin.9052](https://forum.uipath.com/u/benjamin.9052)\
**Post date:** [January 6, 2023, 9:25am UTC](https://forum.uipath.com/t/create-dynamic-array-lists/505200/1 "2023-01-06T09:25:05Z")

</div>

Hi Community ,

i am trying to segregate a list of file names based on the file substring. I have a reference type array and a list of filenames , i need to create a new array of just the file names of the type.

Input :  
Array 1: Filenames list

filelist { C:\Test\Type1-20220410.pdf,  
C:\Test\Type2-20220411.pdf,  
C:\Test\Type3-20220412.pdf,  
C:\Test\Type1-20220413.pdf,  
C:\Test\Type2-20220414.pdf,  
C:\Test\Type1-20220415.pdf,  
C:\Test\Type2-20220416.pdf,  
C:\Test\Type1-20220417.pdf,  
C:\Test\Type1-20220418.pdf}

Array 2 : Reference List

ref{type1,type2}

Expected output :  
Array 1:  
Type1list{C:\Test\Type1-20220410.pdf,  
C:\Test\Type1-20220413.pdf,  
C:\Test\Type1-20220415.pdf,  
C:\Test\Type1-20220417.pdf,  
C:\Test\Type1-20220418.pdf}

Array 2  
Type2list{C:\Test\Type2-20220411.pdf,  
C:\Test\Type2-20220414.pdf,  
C:\Test\Type2-20220416.pdf}

I want to dynamically create these arrays based on the reference list , if later type3 is added to the list . the code should be able to dynamically create 3 array lists .  
Any help would be much appreciated , Thank you.

---

<div class="post-metadata">

**Author:** ![supermanPunch](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/supermanpunch/32/133652_2.png) [@supermanPunch](https://forum.uipath.com/u/supermanPunch)\
**Post date:** [January 6, 2023, 1:35pm UTC](https://forum.uipath.com/t/create-dynamic-array-lists/505200/2 "2023-01-06T13:35:25Z")

</div>

> [@benjamin.9052](#):
>
> I want to dynamically create these arrays based on the reference list , if later type3 is added to the list . the code should be able to dynamically create 3 array lists .

Hi @benjamin.9052 ,

Could you Check with the below Expression :

```auto
arrayGroupedFiles = (From d In Array1
Group d By k=Split(Path.GetFileNameWithoutExtension(d),"-")(0).ToLower Into grp=Group
Where Array2.Any(Function(x)k.Contains(x)) 
Select grp.ToArray).ToList

```

Here, `Array1` & `Array2` are of the type Array of String containing the input data & reference data and `arrayGroupedFiles` is a variable of the type List(Array Of String)

Visuals :  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/d/5/6/d56fb2cb8371675c15789864aea5a2a99a2bab55.png)

Let us know if this is not the expected output.

---

<div class="post-metadata">

**Author:** ![benjamin.9052](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/benjamin.9052/32/177246_2.png) [@benjamin.9052](https://forum.uipath.com/u/benjamin.9052)\
**Post date:** [January 6, 2023, 5:10pm UTC](https://forum.uipath.com/t/create-dynamic-array-lists/505200/3 "2023-01-06T17:10:58Z")

</div>

This is the expected output. This is helpful.

Thank you .

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [January 9, 2023, 5:10pm UTC](https://forum.uipath.com/t/create-dynamic-array-lists/505200/4 "2023-01-09T17:10:59Z")

</div>

Closed on January 9, 2023, 5:10pm UTC

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