using System.Text.RegularExpressions;
string[] GetTheFileName(string[] a)
@"c:\path\to\1109093-A2 (85806S).pdf",
@"c:\path\to\1109093-A3 (85806S).pdf",
@"c:\path\to\1109092-A1 (85806S).pdf",
@"c:\path\to\1109092-A2 (85806S).pdf",
@"c:\path\to\1107359 - A02 (2-Pin-Konnektor).pdf",
@"c:\path\to\1107359-A01 (2-Pin-Konnektor).pdf",
@"c:\path\to\1107359-A03 (2-Pin-Konnektor).pdf",
@"c:\path\to\1109042 - A02 (E7927).PDF",
@"c:\path\to\1109042 - A03 (E7927).pdf",
@"c:\path\to\1109102 - A01 (85915S hellblau).pdf",
@"c:\path\to\1109102 - A06 (85915S hellblau).PDF",
string[] SortFileName(string []TemP)
var paths = GetTheFileName(TemP);
return paths.Select(x => {
string filename = Path.GetFileName(x);
var match = Regex.Match(filename, @"(?<ItemsNumber>\d+)\s*-\s*(?<Revision>\w+)\s+\((?<EndItemNumber>\w.*?)\).[p|P][d|D][f|F]");
return new { ItemNumber = match.Groups[1].Value, Revision = match.Groups[2].Value, EndItemNumber = match.Groups[3].Value, Path = x };
return new { ItemNumber = "", Revision = "", EndItemNumber = "", Path = x };
.GroupBy(x => x.ItemNumber)
.Select(x => x.OrderByDescending(y => y.Revision).First())
.Select(x => x.Path.ToString())
foreach (var p in SortFileName(a))