[MlMt] Copying the contents of a smart folder to a zip file?

Logan Kirkland logan at logankirk.land
Thu May 16 03:25:45 EDT 2024


Hi Steve,

On 15 May 2024, at 20:18, Steven M. Bellovin wrote:

> 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.)
>
>         —Steve Bellovin, https://www.cs.columbia.edu/~smb

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.

```
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
```

--
Logan Kirkland
logan at logankirk.land
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freron.com/pipermail/mailmate/attachments/20240516/c27f8a3f/attachment.htm>


More information about the mailmate mailing list