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

John Doherty jld at jld3.net
Thu May 16 10:36:33 EDT 2024


On Thu 2024-05-16 01:25 AM MDT -0600, <logan at logankirk.land> wrote:

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

Interesting. For me, the kMDItemContentCreationDate is, with two 
exceptions I can't comprehend, the date and time the messages were 
pasted into a directory and bear no relation to the date the messages 
were received. For example:

$ for i in *.eml ; do printf "%s\n" "$(mdls -name 
kMDItemContentCreationDate -raw $i)" ; done | head -4
2024-05-16 00:57:37 +0000
2024-05-16 14:22:59 +0000
2024-05-16 14:22:59 +0000
2024-05-16 14:22:59 +0000

No idea where 2024-05-16 00:57:37 +0000 came from. 2024-05-16 14:22:59 
+0000 is the date and time the files were created, not the date of the 
messages. Similarly:

$ for i in *.eml ; do printf "%s\n" "$(mdls -name 
kMDItemContentCreationDate -raw $i)" ; done | tail -4
2024-05-16 14:22:59 +0000
2024-05-16 14:22:59 +0000
2024-05-16 14:22:59 +0000
2024-05-16 00:57:37 +0000

Again, no idea where 2024-05-16 00:57:37 +0000 came from. It's neither 
the date the message was received nor the date the file was created.




More information about the mailmate mailing list