Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm interested in making a Service (using Automator if possible) that allows me to perform an action on a URL.

If the URL exists as plain text, this works just fine.

However, if the URL is a link in rich text, then my service gets the link's title, rather than it's URL.

How can I obtain the URL when activating a Service on a rich text link?

share|improve this question
Can we assume that no text is selected besides the URL? –  timothymh Feb 22 '12 at 14:52
Yes, just the link is selected. For example, when viewing a message in Mail.app, if I right-click on a link, it selects the entire link (and only the link), and the right-click menu shows Services that accept Text as input. –  smokris Feb 22 '12 at 18:52
The thought just occurred to me: could it be that it's receiving it as a "string" rather than as "text"? This probably isn't what's happening, but I think it's a possibility. –  timothymh Feb 22 '12 at 20:43
@TimothyMueller-Harder: I don't understand — how do "string" and "text" differ? What should I change? –  smokris Feb 23 '12 at 1:00
Never mind—I was thinking Applescript. Upon further Automator research, there's apparently no difference for what you're doing. :) –  timothymh Feb 23 '12 at 1:05

1 Answer 1

You can do it using the app TextSoap. The cleaners "Extract URLs by Replacing" and "Extract URLs by Appending" work with rich text format.

You can also use the following AppleScript:

tell application "textsoap7"
    cleanClipboard with "Extract URLs by Replacing"
end tell
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.