Hello scripters,
After reading the recent posts on rb-appscript I decided to give it a whirl. So I started by just redoing a recent script than came across here and after a little tinkering I got it to work. From there I wanted to try and get the ruby code to run from inside an applescript and this is what I have come up with.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ set rb to "require 'rubygems' require 'appscript' include Appscript require 'osax' include OSAX
# Set Duration Params new_duration = 10
# App Declarations Finder = app('Finder') QT = app('QuickTime Player.app')
theFile = osax.choose_file() theMovie = Finder.files[theFile].name.get savePath = osax.choose_folder()
QT.open(theFile) QT.select_all(theMovie) QT.documents[theMovie].selection_end.set(new_duration * (QT.documents[theMovie].time_scale.get)) QT.documents[theMovie].trim QT.documents[theMovie].save_self_contained(:in => (String(savePath) + '/' + theMovie)) QT.documents[theMovie].close"
set theCommand to "ruby -e \"" & rb & "\"" do shell script theCommand ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here's where I get lost though. If I copy the contents of theCommand and paste it into a terminal window the script runs fine. However when it's ran via the do shell script theCommand I get back this error
-e:1: syntax error, unexpected tIDENTIFIER, expecting $end require 'rubygems' require 'appscript' include Appscript require 'osax' include OSAX
# Set Duration Params new_duration = 10
# App Declarations Finder = app('Finder') QT = app('QuickTime Player.app')
theFile = osax.choose_file() theMovie = Finder.files[theFile].name.get savePath = osax.choose_folder() QT.open(theFile) QT.select_all(theMovie) QT.documents[theMovie].selection_end.set(new_duration * (QT.documents[theMovie].time_scale.get)) QT.documents[theMovie].trim QT.documents[theMovie].save_self_contained(:in => (String(savePath) + '/' + theMovie)) QT.documents[theMovie].close ^
Any ideas what's going on?
Thanks!
James Nierodzik
P Please consider the environment before printing this email. |