Mail - Extract Links
Mail - Extract Links
- Subject: Mail - Extract Links
- From: Christopher Stone <email@hidden>
- Date: Sun, 24 Nov 2013 14:25:08 -0600
Hey Folks,
I don't like iCloud sync for Safari, so when I'm working on my iPad I frequently send myself links to read on the Mac.
The last time I did this I had 20 or so, and it got tedious to open the message, extract the link, open it in Safari, etcetera.
So I wrote a script to do the heavy lifting.
-------------------------------------------------------------------------------------------
set _content to {}
tell application "Mail" set sel to selection if sel = {} then return repeat with i in sel set _content to _content & content of i end repeat end tell
set AppleScript's text item delimiters to linefeed set _content to _content as text set _content to do shell script "<<< " & quoted form of _content & ¬ " tr '\\r' '\\n' | sed -En '/^https?: \\/\\/.+/p' | tr '\\n' '\\r'" without altering line endings
tell application "BBEdit" activate set newDoc to make new text document with properties {text:_content} set bounds of newDoc's window to {0, 44, 1920, 1200} end tell
-------------------------------------------------------------------------------------------
I have another script that will open links in the front BBEdit window in Safari that works well with this.
Eventually I'd like to make the script robust enough to handle encoded email and html email, but I think I'm going to need modules in Perl and haven't figured out how to load them via MacPorts yet.
Finally: I think do shell script may be a little bit faster in Mavericks. The above script is damn near as fast as my Satimage.osax version.
-- Best Regards, Chris
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden