lib/digitalfilmtree/vfx/edl_ml_renamer.rb in digitalfilmtree-0.0.4 vs lib/digitalfilmtree/vfx/edl_ml_renamer.rb in digitalfilmtree-0.0.5

- old
+ new

@@ -2,11 +2,11 @@ require 'edl' module Digitalfilmtree module VFX class EDLMLRenamer - attr_accessor :ml, :edl, :movs + attr_accessor :ml, :edl, :movs, :ml_name_column attr_reader :folder, :count def folder=(path) @folder = path self.ml = self.glob(".txt").first @@ -20,12 +20,13 @@ self.movs.size >= 1 end def execute raise "Not Ready" unless ready? - @count = 0 parse_marker_list + get_marker_list_name_column + @count = 0 EDL::Parser.new.parse(File.open(self.edl)).each do |e| find_clip(e.reel) do |path| timeline_tc_in = e.rec_start_tc.to_s get_vfx_name(timeline_tc_in) do |vfx_name| new_path = path.gsub(File.basename(path), "#{vfx_name}.mov") @@ -37,13 +38,29 @@ end end protected + def get_marker_list_name_column + row = @ml_data.first + loop do + if self.ml_name_column && row[self.ml_name_column] + puts "Using marker list column index #{self.ml_name_column} for the Name" + break + else + puts "Please enter the number mapping to the Name column in the marker list:" + row.each_with_index do |e,i| + puts "#{i}) #{e}" + end + self.ml_name_column = STDIN.gets.strip.to_i + end + end + end + def get_vfx_name timeline_tc_in, &block row = @ml_data.select{|r| r.include? timeline_tc_in } - name = row.flatten.first + name = row.flatten[self.ml_name_column] block.call(name) if name end def find_clip reel, &block clip = self.movs.select{|i|i.match(/#{reel}/)}.first @@ -56,10 +73,10 @@ def glob(patt) entries = Dir.entries(self.folder).select do |i| i.include? patt end - if sep = File::ALT_SEPARATOR + if sep = File::ALT_SEPARATOR # Windows support entries.map do |entry| File.join self.folder, sep, entry end else entries.map do |entry|