Sort out audio files using filetype not extension?

Desktop
Is there a way to sort out (for example) audio files using filetypes?
Currently I use this

If fStr.EndsWith("wav") Then

This is just one extension, but I’d like to use FileTypes.audio to sort with, but I can’t think of way to do this?
Am I missing something?

You can iterate over the FileType objects in a FileTypeGroup using the AllFileTypes property:

Var allTypes() as FileType = FileTypeGroup1.AllFileTypes

Or access a specific one:

Var audioType as FileType = FileTypeGroup1.Mp3

You can then retrieve the Extensions property and split by semicolon for all extensions:

Var ext() as String = audioType.Extensions.Split(";")

Which you can then iterate in your sort function.

This function might give you a sense of how to accomplish what you’re after:

Public Function isAudio(f as FolderItem) As Boolean
  var extensions() as String = FileTypeGroup1.Mp3.Extensions.Split( ";" )
  var fileExtension as String = "." + f.Name.LastField( "." )
  
  return extensions.IndexOf(fileExtension) >= 0
End Function

Thanks. I guess on the simple side I’m not missing out on a different technique.
On the learning side, I hadn’t thought to iterate through the types and grab the extension.

1 Like