Search code examples
applescriptnuke

applescript to render nuke script in terminal


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.


Solution

  • 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