Question - Parsing filenames and filetypes

I’m trying to create a utility that will parse 50,000 files in a folder.
The files are either type .mid or .all (music files)
The files are in pairs eg:
verygoodsong.mid - verygoodsong.all - Song2.mid - Song2.all etc.
All the filenames are different. Anyway I need the utility to read the folder with the files - Check whether there’s a pair of files with the same filename (but different file type) - IF NOT Write the missing filename to a text document -
Here’s were I am at the moment - I thought it would be easier using a ListBox.
I have a window with a Listbox and select button and a label - select button code

Dim dlg As New SelectFolderDialog
dlg.ActionButtonCaption = “Select”
dlg.Title = “Folder Selection”
dlg.PromptText = “Choose”
Dim f As FolderItem
f = dlg.ShowModal
If f <> Nil Then
for i as Integer=2 to f.Count //setting the start at 2 then ignores the .DS_Store file
listbox1.addrow f.Item(i).name
//DO A COMPARE BIT
next
Else
// User cancelled
End If

//Update the list total
Label2.Text = Str(ListBox1.ListCount)

Anyway this gets the listbox populated ok …Im fine with writing to the text document from the listbox - its the RIGHT str compare bit that’s getting me for the file type Maybe I don’t need to use a listbox?

Would you want to check 50k files? I wouldn’t think so. If your algorithm knows what to do then you don’t need a listbox.

If the utility is customer-facing use FileListMBS from the MBS plugin to loop over the 50 files. It’s so much faster than the Xojo code.

Im guessing that its the non-alphabetical nature of the filenames being returned that is the issue.
read them in, add them to an array, sort it, then work through that?