There are many scales with different keys for the same notes.

For example, with the notes C D E F G A B C,
we can have: C major, C Ionian, A natural minor, D Dorian, E Phrygian, F Lydian, G Mixolydian, A Aeolian, B Locrian.

I understand that music in these scales have different tonal centers and sound different. I can detect a key by ear or while looking at song notes in my DAW.

But I want to categorize bunch of MIDI files by scales and keys. So i need to find a way to do it without hearing music or viewing notes/sheets.

Maybe some methods are exist? For example statistics of most frequently used note, or note with which most of bars are started, most frequent base of chord etc?