Skip to content

Instantly share code, notes, and snippets.

@nycdavid
Last active June 10, 2016 16:22
Show Gist options
  • Save nycdavid/423312c79f7530401ccd to your computer and use it in GitHub Desktop.
Save nycdavid/423312c79f7530401ccd to your computer and use it in GitHub Desktop.
AvidMover class
require "fileutils"
class AvidMover
Bin = Struct.new(:type, :genre, :filename)
def initialize(project_path)
@project_path = project_path
end
def move_bins
@bin_names = Dir.glob("#{@project_path}*.avb")
@bin_names.each do |name|
source = name
split_name = name.split("/").last.split("-")
bin = Bin.new(split_name[0], split_name[1], split_name[2])
dest_path = "#{@project_path}#{bin.type}/#{bin.genre}/"
dest = "#{dest_path}#{bin.filename}"
begin
unless Dir.exist? dest_path
FileUtils.mkdir_p dest_path
end
FileUtils.mv source, dest
puts "Moving to #{dest}"
rescue
puts "Can't move to #{dest}"
next
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment