I have a folder of emails. The body of each message contains a single web link, and some text I don’t care about.
I want to automatically create one file summarizing the folder. The table would consist of a first column listing the email’s subject and a second column containing the link.
The table can be CSV, tab-delimited, or anything easy to implement.
The folder contains about 100 emails.
I find regex difficult, so if the suggestion involves regex to find the link, I could use some help there. I understand using regex to find links is easy, but the regex help sites are very opaque, at least to me.
I made a bad choice in my use of words. “Used” would be better.
I figure using Regex to find something like https://www.youtube.com…and whatever comes after that in the link… would be relatively easy. But I don’t understand Regex, and someone who does might be able to come up with a solution.
Regex is probably not necessary if your links share the same format.
e.g. If the link always start with http, and at the end is immediately followed by either a space or a new line, then use AppleScript:
set theText to the plain text of theRecord
set tempTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to "http"
set theText to the second text item of theText
try
set AppleScript's text item delimiters to "\n"
set theText to the first text item of theText
end try
try
set AppleScript's text item delimiters to " "
set theText to the first text item of theText
end try
set theLink to "http" & theText
set AppleScript's text item delimiters to tempTID
I just ran it through the Apple Mail. I created a workflow that dumped the contents of all selected mail messages into one file and then used the standard “extract URLs from Text” command to get a list of URLs added to a TextEdit document. I don’t know why the list wasn’t created in the selection order from Apple Mail (I would be interested if anyone knows - since I could use this to get the subjects separately with AppleScript), but it got me the links, which is most of what I wanted.
I attached a copy of the Automator script (zipped) if anyone is interested.