Simple and (should have been obvious):
I have been using this in some cases but I did not know about the -t option.
The previous post reminded of one of the oldest scripts I have and still use regularly. I regularly have to gather information found on different webpages and email them to somebody. I try to gather all the relevant webpages in tabs in one Safari and then run this script. It will look at all the tabs in the frontmost Safari Window and build a plain text list out of the titles and links and place that in clipboard, ready to paste into an email or elsewhere.The result will look like this:
Apple <http://www.apple.com/> Google <http://www.google.com/> Scripting OS X | #! is not a curse word <https://scriptingosx.com/>
The script is fairly straightforward:
global linkText on run set linkText to "" tell application "Safari" activate set w to window 1 set n to 0 try -- this will fail for the downloads window set n to count tabs of w end try if n > 1 then repeat with t in every tab of w my appendLineWithDoc(t) end repeat else if n = 1 then my appendLineWithDoc(document of w) end if end tell set the clipboard to linkText return linkText end run on appendLineWithDoc(theDoc) tell application "Safari" tell theDoc try set linkText to linkText & name set linkText to linkText & return & "<" & URL & ">" & return & return end try end tell end tell end appendLineWithDoc
You can save this script in your ~/Library/Scripts/Applications/Safari folder and enable the Script menu and it will be shown only in Safari.
This could be a very useful script for other tools as well:
Nice tool with an honorable mention of yours truly…
This is a wonderful overview over where workflows and scripts have to be to be found by their respective applications and tools.
Looks like an interesting tool to enhance AppleScript functionality. I also like the way they distribute it as an App through the App Store.
This looks very, very interesting, I’ll be looking forward to it.
I’d be totally remiss not to mention this, just go and read it: