Last active
June 6, 2022 00:17
-
-
Save dreness/f7de9bbf861d6f9ae821 to your computer and use it in GitHub Desktop.
Show recent file attachments from Message.app's chat DB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- sqlite3 ~/Library/Messages/chat.db < recent-attachments.sql | |
-- dates in the DB are NSDate. NSDate.h says: NSTimeIntervalSince1970 978328800 | |
select | |
Datetime( | |
created_date + strftime("%s", "2001-01-01"), | |
"unixepoch", | |
"localtime" | |
) as created, | |
mime_type, | |
Printf( | |
"%.2f", | |
Cast (total_bytes AS FLOAT) / 1000 / 1000 | |
) 'megabytes', | |
handle.id 'buddy', | |
filename | |
FROM | |
attachment | |
JOIN message_attachment_join ON message_attachment_join.attachment_id = attachment.rowid | |
JOIN chat_message_join ON chat_message_join.message_id = message_attachment_join.message_id | |
JOIN chat_handle_join ON chat_handle_join.chat_id = chat_message_join.chat_id | |
JOIN handle ON handle.rowid = chat_handle_join.handle_id | |
WHERE | |
Strftime('%s', 'now') - (created_date + 978328800) < (60 * 60 * 24 * 7); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment