2

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.

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432

2 Answers2

1

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
jweaks
  • 3,674
  • 1
  • 19
  • 32
  • This worked perfectly. You've helped me out enormously! – magicbeansvfx Oct 12 '15 at 20:26
  • I've uploaded the droplet for download. Many thanks again to jweaks. [NUKE – APPLESCRIPT DROPLET TO RENDER NUKE SCRIPTS IN TERMINAL](https://magicbeansvfx.wordpress.com/2015/12/03/nuke-apple-script-droplet-to-render-nuke-scripts-in-terminal/) – magicbeansvfx Dec 10 '15 at 16:28
0

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
pbell
  • 2,965
  • 1
  • 16
  • 13