<div class="markdown">
<p dir="auto">On 22 Nov 2013, at 9:44, mailmate wrote:</p>
<blockquote>
<p dir="auto">I need to copy a part of a subject kind of:</p>
<pre><code>ex Subject: Serial: XHGFSTW - File: 509393 - Reference: 43467
</code></pre>
<p dir="auto">I need to copy ex the serial of the file number to lookup this info in another application.</p>
<p dir="auto">Any idea how this can be done easily.</p>
</blockquote>
<p dir="auto">The GUI currently only supports right-click and then Copy followed by editing the text when it's pasted. Obviously not easy.</p>
<p dir="auto">This is one of those small things which would be nice to automate. Using the experimental commands system then you could do it with the following command:</p>
<pre><code>{
name = 'Copy Serial';
input = 'formatted';
formatString = "${subject/Serial: (\\S*) .*/$1/}";
script = '#!/usr/bin/pbcopy\n';
keyEquivalent = "F";
uuid = 'C2561103-D9BA-43C5-AB4D-5AC7FDA5A77B';
}
</code></pre>
<p dir="auto">This would allow you to just hit ⇧F and then the serial value (XHGFSTW) would be on the pasteboard.</p>
<p dir="auto">The problem is that there is currently no way you could have created the above yourself (undocumented and no GUI), but you have been a major contributor to the crowd funding campaign and you deserve your own bundle of commands. I've attached a simple start. Unzip it and then place it here:</p>
<pre><code>~/Library/Application Support/MailMate/Bundles/
</code></pre>
<p dir="auto">(Also enable experimental 2.0 features in the General preferences pane.)</p>
<p dir="auto">For you and the rest of the mailing list, here is a quick dissection of the command:</p>
<pre><code> name = 'Copy Serial';
</code></pre>
<p dir="auto">The name of the menu item placed in the Command menu.</p>
<pre><code> input = 'formatted';
</code></pre>
<p dir="auto">The input format. This tells MailMate that the input to the script (stdin) should be the result of a format string based on the currently selected message(s).</p>
<pre><code> formatString = "${subject/Serial: (\\S*) .*/$1/}";
</code></pre>
<p dir="auto">The formatString uses the subject of the message, but it's altered using a regular expression substitution. This locates the serial number in the subject and uses it as the result. (It is incomprehensible if you have no experience with regular expressions.)</p>
<pre><code> script = '#!/usr/bin/pbcopy\n';
</code></pre>
<p dir="auto">The script to be executed is extremely simple. It's just a system command used to put the input on the pasteboard.</p>
<pre><code> keyEquivalent = "S";
</code></pre>
<p dir="auto">The command can be executed using ⇧S (as an alternative to using the menu item).</p>
<pre><code> uuid = 'C2561103-D9BA-43C5-AB4D-5AC7FDA5A77B';
</code></pre>
<p dir="auto">Each command must have a unique identifier.</p>
<p dir="auto">Final note: I introduced the <code>formatted</code> input format mainly to easily select a large number of messages and then retrieve a simple value from each of them. For example, one could easily retrieve all sender addresses and then send them through <code>sort | uniq -c | sort -r | head</code> to get a list of the 10 most frequent senders.</p>
<p dir="auto">-- <br>
Benny</p>
</div>