How can i group a file depends on the file name that is similar to other file, the only difference is the last letter on the file name

Hello Guys, how can i select or group the files that is similar number but only different on the last letter of the file name

Thank you so much

For your reference here is the picture

Hi,
You can read all the filenames and use a regular expression to match every group of files. If a filename matches with the regex of a particular group, you can process that file to that particular group. Otherwise, you need to check the remaining regex for other groups.

HI,

How do you want to handle at last?
The following is a simple sample for grouping with first 14 characters in each file name. Can you try this?

 dict = files.GroupBy(Function(f) System.IO.Path.GetFileNameWithoutExtension(f).Substring(0,14)).ToDictionary(Function(g) g.Key,Function(g) g.ToArray())

Sample20230516-6L.zip (18.6 KB)

Regards,

1 Like

Wow thank you so much, it works for me

1 Like

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