Open ALL Links Script


#1

Hey Omnifocus community,

I am looking for help in finding a script that will open all links I have have in all selected task’s note field.

I use one currently that will open 1 link from a tasks note field and will only open 1 url at a time - to clarify, the script I have is only capable of opening 1 task and in that task, it will only open the first URL.

I would like a script that can open all links in a task and open all links of all selected tasks (if I have 4 tasks selected)

Anyone know if this exists? This feature exists in 2do


#2

Can you post the script you have here? I’m betting it can be altered to do what you want.


#3

Hey Joe, thanks for offering to help! I actually use one of your scripts that I found on the interwebs for my reviews, feels a bit like meeting a celebrity, lol. I am using this script http://jesse.hollington.ca/2016/05/getting-focused-with-omnifocus.html


#4

That looks fairly straightforward. I could see some value in this within my own workflows from time to time. I don’t have time tonight to look into it but I’ll add it to my list. 😉

Nice! I’m glad I could help out. That reviews script has seen a lot of mileage.


#5

I’ve only done minor testing on this but it seems to work. Give it a go and let me know.

tell application "OmniFocus"
	tell content of first document window of front document
		set selectedTasks to selected trees
		if ((count of selectedTasks) < 1) then
			display alert "You must first select tasks to search for links." message "Select a tasks from which you want to open links." as warning
			return
		end if
		repeat with taskNum from 1 to count of selectedTasks
			set curTask to value of item taskNum of selectedTasks
			set paragraphCount to count of paragraphs of note of curTask
			if paragraphCount > 0 then
				repeat with paragraphNum from 1 to paragraphCount
					set curParagraph to paragraph paragraphNum of note of curTask
					if text of curParagraph is not "" then
						set curLink to value of attribute named "link" of style of paragraph paragraphNum of note of curTask
						if curLink begins with "App:" then
							set curLink to text 6 thru -1 of curLink as string
							tell application target to activate
						else if curLink contains "://" then
							do shell script "open " & curLink
						end if
					end if
				end repeat
			end if
		end repeat
	end tell
end tell

#6

Joe,

This works almost perfectly. If i select X amount of tasks whom’s note contains a URL, it will open them perfectly. The only error I am noticing is the script will open duplicate URL’s when a task contain’s multiple URL’s.

Example: If I have 1 ESPN link and 1 Facebook link, it will open 3-4 links.

I did some basic testing and it seems to only do this when there is an ‘enter’ break between lines. Anywho, in it’s current state it is better than what I had before and much appreciated, it saves me so much time in my workflow I am happy to donate some money your way. I noticed you had a $17 subscription so as my thanks, I will learn some more from ya and support your work.


#7

Double check your note formatting and how the links are created. The only way I can duplicate this is with malformed formatting. Namely, if I have the url text in the note but it’s split in the middle with the same hyperlink added to two sides of the text.

I haven’t been able to replicate this at all. Is there something else unique to it?

😊


#8

I’ll test this further at work and update you. Either way, I’m more than pleased


#9

I can’t find anything unique other than the two enter breaks between URL’s. I’ve tested on my Mac pro at home and my mac air at work. I can absolutely just be more mindful when inputting URL’s into notes and address this problem. If you are able to recreate the issue and adjust the script, let me know.

Much Appreciated


#10

Thank you so much for this! 😃


#11

Checked out your video tutorials, great stuff.


#12

I just found this and tried this out. Works like a charm. Thanks, Joe!