Group by first letter?

When I group by filename, the group sizes are large, and everything gets dumped into just a few buckets. How can I group by first letter, so each letter has its own group, even if there's just one file there?

Script columns can provide custom/arbitrary grouping.

OK, I managed to edit one of your scripts to make it work, but how can I ignore 'The ' and 'A ' at the beginning?

Function OnBrackets(scriptColData)
   If (scriptColData.col <> "Letter") Then
      Exit Function
   End If
   If (re Is Nothing) Then
      ' re made the first time the column is requested, then cached.
      Set re = new RegExp
      re.pattern = "(.)(.*)"
   End If
   If (re.Test(scriptColData.item.name_stem)) Then
      scriptColData.value = re.Replace(scriptColData.item.name_stem, "$1")
   End If
End Function

The script can put anything it wants into the column's value and/or group properties. (You can have separate values and groupings if you wish. e.g. The column could show the full name but group by the first letter.)

ScriptColumnData has info on both properties.

If you want to skip "The " and "A " at the beginning, just change the code to look for them and remove them from the value or group. With the existing script, changing the regex to (The |A )(.)(.*) and the replacement to $2 will probably do it.

Thanks Leo. I needed to add a ? but now it's working.

(The |A )?(.)(.*)