<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body><div style="font-family: sans-serif;"><div class="markdown" style="white-space: normal;">
<p dir="auto">Hi Steve,</p>
<p dir="auto">On 15 May 2024, at 20:18, Steven M. Bellovin wrote:</p>
</div><blockquote class="embedded" style="margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; color: #777777;"><div id="2532D982-FF96-4345-9AE4-8356792D32EE">
<div style="font-family: sans-serif;">
<div class="plaintext" style="white-space: normal;">
<p dir="auto">Is there any rational way to copy every message in a smart folder to a single zip file, preserving the date order? If I cmd-C the list of messages and copy/paste the files somewhere (or do the same via the command line), the order is quasi-random, not preserving dates. (I'm perfectly happy to do any sort of weird stuff from the command line.)</p>
<p dir="auto">—Steve Bellovin, <a href="https://www.cs.columbia.edu/~smb" style="color: #3983C4;">https://www.cs.columbia.edu/~smb</a></p>
</div>
</div></div></blockquote>
<div class="markdown" style="white-space: normal;"><p dir="auto"><br>
This worked for me in fish shell. Copy the files, then execute this to do some translations on the “content created” field and save it back to the “date created” field.</p>
<pre style="margin-left: 15px; margin-right: 15px; padding: 5px; background-color: #F7F7F7; border-radius: 5px 5px 5px 5px; overflow-x: auto; max-width: 90vw;"><code style="margin: 0 0; border-radius: 3px; background-color: #F7F7F7; padding: 0px;">for file in *.eml
set created (mdls -name kMDItemContentCreationDate -raw "$file" )
set translated (date -jf "%Y-%m-%d %H:%M:%S %z" "$created" "+%Y-%m-%d %I:%M:%S %p" | sed 's/\([0-9]\{4\}\)-\([0-9]\{2\}\)-\([0-9]\{2\}\) \([0-9]\{2\}\):\([0-9]\{2\}\):\([0-9]\{2\}\).*$/\2\/\3\/\1 \4:\5:\6/')
SetFile -d "$translated" "$file"
end
</code></pre>
<p dir="auto">--<br>
Logan Kirkland<br>
<a href="mailto:logan@logankirk.land" style="color: #3983C4;">logan@logankirk.land</a></p>
</div>
</div>
</body>
</html>