I want to be able to drop a Nuke script on to an Applescript application and then for the Nuke script to start rendering in a terminal.
The script needs to get the file path of the dropped item, paste that in to a terminal window along with 'nuke -xi ' and then hit return. So far I have..
on open dropped_item
get the POSIX path of dropped_item
and...
tell application "Terminal"
if not (exists window 1) then reopen
activate
end tell
Any ideas would be greatly appreciated.
This shouldn't be hard. Just design a good droplet format to handle the file. You want to convert the alias of a file selected to a the posix path to that file.
on run
set this_item to choose file with prompt "Select nuke script to run."
process_item(this_item)
end run
-- This droplet processes files dropped onto the applet
on open these_items
repeat with i from 1 to the count of these_items
set this_item to item i of these_items
process_item(this_item)
end repeat
end open
-- this sub-routine processes files
on process_item(this_item)
set p to POSIX path of this_item
tell application "Terminal"
activate
do script "nuke -xi " & quoted form of p
end tell
end process_item
I don't know what Nuke is doing, but I assume it will create a file as output, so I suggest to not use Terminal, but instead 'do shell script' command.
Your terminal command will look like : nuke -xi /Users/file_path
The script bellow performs that without opening terminal Window
on open MyNukeScript -- trigger the script when file is droped on it
set MypathScript to quoted form of (POSIX path of MyNukeScript)
try
do shell script "nuke -xi " & MypathScript
end try
end open