Which type add folder

I have three folder in my D drive like that name folder 1 , folder 4, folder 9.
so, i need with robot firstly see and find last folder name and new folder with “folder 10”.
and if last folder different like folder 3 then new folder “folder 4”

so, which type i can do this task?

Hello @rAE_rAS,

You can get all the file from the folder in a list and sort the list and get the last file name from the list and extract the numeric value from that and check the number.

Thanks,
Sanjit

@rAE_rAS Get Latest SubFolder from Folder and the get last digit from it and create new with increament of it. simple

Assign Activity:
arrFolderPaths | String Array =

(From fi In New DirectoryInfo(YourRootFolderPath).GetDirectories()
Let no = System.Text.RegularExpressions.Regex.Match(fi.Name,"\d+").Value
Order by CInt(no) DESCENDING
Select fi.FullName).toArray

Kindly note: we need the conversion to the number as otherwise, we do sort wrongly lexically
grafik

I need last folder name and add one number in that and create one new folder…can you say with activity and expression

can you explain in details?

@rAE_rAS listen
suppose there is no folder
then I created one Folder1.
then I check latest one so I get Folder1
then I get name and placed Folder2
again I checked latest folder then I get Folder2
Then I get name of it and Folder3
so it will repeat in every time

but their are so many folder

@rAE_rAS brother use linq it will get only latest

Bro i dont need latest folder name …I only need last one folder name

the folder sortings was given above
arrFolderPaths.First() would return the latest folder path

when it is about the max number calculation then we can do:

@rAE_rAS So you want to ignore creation time and just base of name you want get last folder

Hello @rAE_rAS,

As peter expalined
Assign the below code to the String[ ] variable

Let no = System.Text.RegularExpressions.Regex.Match(fi.Name,"\d+").Value
Order By CInt(no) Descending
Select fi.FullName).toArray

Assign the below code to the Int32 variable

CINT(System.Text.RegularExpressions.Regex.Match(Path.GetFileNameWithoutExtension(numberArray(0)),"\d+").Value)

image

You will get the required result.

Thanks,
Sanjit

Number array = ?

The number array containes the folder paths in a descending order.

PFA the xaml for your reference.
Test.xaml (5.8 KB)