service to open </path/to/filename>

Discussion in 'Mac Programming' started by boeufhead, Mar 21, 2014.

  1. boeufhead, Mar 21, 2014
    Last edited: Mar 21, 2014

    boeufhead macrumors newbie

    Mar 21, 2014
    i'm sure the answer is out there but i've been unable to find it.

    i want to make a service using applescript/automator so that when i control click on a text selection in whatever programme it opens the file with the default application and gives me a can't find file dialogue if it can't find the file.

    so say this is the selected text
    i want to be able to control click on that text and have a service open the file in preview...

    any help much appreciated!
  2. kryten2, Mar 22, 2014
    Last edited: Mar 23, 2014

    kryten2 macrumors 6502a

    Mar 17, 2012
    Take a look at the open command.

    Quote from the man page :

    Info : Open Manual Page
  3. boeufhead thread starter macrumors newbie

    Mar 21, 2014
    thank you so much. that is useful... but i was looking to create a service in automator that would act on a text selection.

    so say the text selection is file:///Users/testuser/Desktop/testimage.png
    i want to be able to control click on that selection and have it open that file.

    so i know how to make a service in automator but (and i guess this is a real newbie question...) how do i pass the selected text to a script so that it opens that file when i control click??
  4. subsonix macrumors 68040

    Feb 2, 2008
    Open is already a system included service, select text in the form of a file path and it will appear in the context menu: services/open or open URL.

    But it would be easy to do what you are asking, you need to pick selected text in any program as input, then use the run shell script action, with the open command.

Share This Page