#! /usr/bin/env ruby require 'pp' class Fixnum def pad(n) x = self.to_s if x.length < n pad = "0"*(n - x.length) x.insert(0,pad) else x end end end def render(filepath,last_frame) IO.popen("shake -v xml -exec #{filepath} -t 1-#{last_frame}x1", 'r+') end def get_last_frame(file_path) last_frame = File.open(file_path).grep(/SetTimeRange/).to_s.scan(/\d{2,6}/).first.to_i end def get_output_file(file_path) out_file = File.open(file_path).grep(/FileOut/).first.gsub(/\"/,"").split(",")[1].lstrip end def get_quality(file_path) quality = File.open(file_path).grep(/SetUseProxy/).first.match(/\".+\"/).to_a.first end # Get location of scripts $renderQ = {} puts "Where are the scripts?" $TARGET = gets.rstrip $TARGET << "/" if $TARGET !~ /\/$/ $script_list = %x| ls #{$TARGET}*.shk |.split("\n") # Only files with *.shk extension # Replace whitespace (if present) in filenames with underscores $script_list.map! do |f| new_name = f.gsub(/\s/,'_') unless f == new_name puts "Renaming #{f} --> #{new_name}" File.rename(f,new_name) end new_name end # Make sure all renders are full-resolution $script_list.each do |f| file,path,filename = File.open(f), File.dirname(f), File.basename(f).split(/\./) unless file.read.grep(/SetUseProxy/).first =~ /Base/ new_file = File.open(f).read.gsub!(/^SetUseProxy.+;$/,'SetUseProxy("Base");') File.open(f,'w') { |f| f.puts new_file } end end # Get render info on scripts $script_list.each do |f| outfile = get_output_file(f) last_frame = get_last_frame(f) quality = get_quality(f) $renderQ[f] = [last_frame,quality,outfile] end # Print report puts "\n---------| RENDER SCRIPT -- FRAME COUNT -- OUTPUT FILE |---------\n" $renderQ.sort.each { |k,v| puts "#{k} -- #{v.first} --> #{v.last} | #{v[1]}" } puts "---------------------------------------------------" puts "\nPress Enter to continue with render, or force exit." gets # Render $renderQ.each { |k,v| render(k,v.first) }
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Ruby: Submit Apple Shake Scripts for Batch Render (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» Ruby: Apple Shake - Report F... in ruby apple shake
» Copy files matching a regula... in ruby script file rename
» Ruby: Apple Aperture API in ruby apple activerecord sqlite api aperture module
» Aperture Duplicate Finder | ... in ruby apple aperture
» Typo under lighttpd in lighttpd ruby rails typo ruby-fcgi
» password hash script in ruby password
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails