Skip to content

Instantly share code, notes, and snippets.

@ianchesal
Last active June 17, 2022 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianchesal/34bb82dc5565eccd88f54c4f1c371d55 to your computer and use it in GitHub Desktop.
Save ianchesal/34bb82dc5565eccd88f54c4f1c371d55 to your computer and use it in GitHub Desktop.
Auto-Organize Your Fractal-Bot Backups
#!/usr/bin/env ruby
# ***USE***
# Drop this file into the folder where you have Fractal-Bot storing your
# backups. Name it whatever you like. Run it from time to time and it'll
# sort your backups into sub-folders based on file prefixes.
#
# If you're on a Mac you can use this code as a Folder Automation action and
# it should work just fine and run every time a new file is created in your
# backup folder.
#
# ***REQUIRES***
# Fractal-Bot v3.0.8 or newer
require 'fileutils'
# Add new devices you're backing up to this list
supported_devices = %w[FM3 III AX8 FM9]
Dir.chdir(__dir__) do
supported_devices.each do |subdir|
next if File.directory? subdir
puts "Making ./#{subdir}"
FileUtils.mkdir_p subdir
end
Dir.glob('*.syx') do |sysexfile|
next unless File.file? sysexfile
subdir = sysexfile[0..2]
next unless supported_devices.include? subdir
puts "Moving #{sysexfile} to ./#{subdir}/"
FileUtils.mv(sysexfile, "./#{subdir}/#{sysexfile}")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment