Sorting Sound Files using Ruby


Consider you have 2,248 files in a directory, each containing one single sound program for your favourite Z1 synth. You need to load them into the synth individually, listen to them and to sort them in directories. Painful it would be.

Fortunately, all sounds are set to one of 18 predefined categories like guitar, synth hard, synth soft, piano, organ and the like. In the SysEx files, the category is coded into the 26. byte. So it was easy to sort the files into subdirectories using a couple of lines of Ruby code (sorry for the misformatting):

#! /usr/bin/ruby

require 'fileutils.rb'

def determineCategory( filename )
file = filename, "rb:binary" )
fileContents =
category = fileContents[25] + 1
# puts filename, category
Dir.mkdir( category.to_s )
end filename, category.to_s )

Dir.glob( '*.[Ss][Yy][Xx]' ) do |entry|
determineCategory entry

1 thought on “Sorting Sound Files using Ruby

Comments are closed.