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”
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.
(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
@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