Page 1 of 2

Rule based on "Date Last Opened" not matching

PostPosted: Wed Jul 19, 2023 8:53 am
by witchhazel
Hello, I am trying to create a workflow to tag files after a certain time since last opened and untag those opened within the last 7 days.

The rule hasn't been matching. When I check Hazel's Rule Status, it's not matched. Checking the info of the file, the Date Last Opened doesn't match what MacOS shows in Finder.

Finder shows the file open today, but Hazel Rule Status shows the file not opened since Jan, the date it was last opened/modified before I opened it today.

Is this a MacOS issue or Hazel or is my rule incorrect?

Thanks!

Re: Rule based on "Date Last Opened" not matching

PostPosted: Wed Jul 19, 2023 9:02 am
by Mr_Noodle
Where in Finder are you looking at Date last opened? If it's a regular Finder window, those dates cannot be trusted. Select the file and do "Get Info". Report back with the date listed there.

Re: Rule based on "Date Last Opened" not matching

PostPosted: Wed Jul 19, 2023 9:07 am
by witchhazel
Mr_Noodle wrote:Where in Finder are you looking at Date last opened? If it's a regular Finder window, those dates cannot be trusted. Select the file and do "Get Info". Report back with the date listed there.

Looking in the "Info" of the file.

Created: Jan 23, 2023 at 8:08 PM
Modified: Jan 23, 2023 at 8:08 PM
Last Opened: Today, 8:12 AM
Added: Jan 23, 2023 at 8:08 PM
Attributes: Today, 8:12 AM

Re: Rule based on "Date Last Opened" not matching

PostPosted: Thu Jul 20, 2023 9:28 am
by Mr_Noodle
Can you post a screenshot of what the date is in Hazel?

Re: Rule based on "Date Last Opened" not matching

PostPosted: Thu Jul 20, 2023 10:01 am
by witchhazel
Sure. I can't figure out how to upload here. The FAQ says I need to be enabled. I don't see the option though. Here are links to imgur where I uploaded the images for now.
https://imgur.com/GvydYmV
https://imgur.com/j3ERVHQ

Re: Rule based on "Date Last Opened" not matching

PostPosted: Fri Jul 21, 2023 9:30 am
by Mr_Noodle
Sorry, but can you also post a pic of the Finder's "Get Info" on the file? Also, are you comfortable using the commandline?

Re: Rule based on "Date Last Opened" not matching

PostPosted: Fri Jul 21, 2023 2:57 pm
by witchhazel
Mr_Noodle wrote:Sorry, but can you also post a pic of the Finder's "Get Info" on the file? Also, are you comfortable using the commandline?

Not a screenshot, but here is the same information from the Finder screenshot

Created: Jan 23, 2023 at 8:08 PM
Modified: Jan 23, 2023 at 8:08 PM
Last Opened: Today, 8:12 AM
Added: Jan 23, 2023 at 8:08 PM
Attributes: Today, 8:12 AM

https://imgur.com/a/u6SVSzF

And yes, very comfortable with commandline

Re: Rule based on "Date Last Opened" not matching

PostPosted: Mon Jul 24, 2023 8:37 am
by Mr_Noodle
Can you post a screenshot of the whole Get info window?

Also, post the output of the 'mdls' command on the file.

Re: Rule based on "Date Last Opened" not matching

PostPosted: Mon Jul 24, 2023 1:33 pm
by witchhazel
Mr_Noodle wrote:Can you post a screenshot of the whole Get info window?

Also, post the output of the 'mdls' command on the file.


Sure.

Image: https://imgur.com/a/dEEkny0

Code: Select all
user@mac Downloads % mdls redacted_filename.pptx
_kMDItemDisplayNameWithExtensions  = "redacted_filename.pptx"
kMDItemContentCreationDate         = 2023-01-24 01:08:22 +0000
kMDItemContentCreationDate_Ranking = 2023-01-24 00:00:00 +0000
kMDItemContentModificationDate     = 2023-01-24 01:08:23 +0000
kMDItemContentType                 = "org.openxmlformats.presentationml.presentation"
kMDItemContentTypeTree             = (
    "org.openxmlformats.presentationml.presentation",
    "org.openxmlformats.openxml",
    "public.data",
    "public.item",
    "public.presentation",
    "public.composite-content",
    "public.content"
)
kMDItemDateAdded                   = 2023-01-24 01:08:22 +0000
kMDItemDisplayName                 = "redacted_filename.pptx"
kMDItemDocumentIdentifier          = 0
kMDItemFSContentChangeDate         = 2023-01-24 01:08:23 +0000
kMDItemFSCreationDate              = 2023-01-24 01:08:22 +0000
kMDItemFSCreatorCode               = ""
kMDItemFSFinderFlags               = 0
kMDItemFSHasCustomIcon             = (null)
kMDItemFSInvisible                 = 0
kMDItemFSIsExtensionHidden         = 0
kMDItemFSIsStationery              = (null)
kMDItemFSLabel                     = 0
kMDItemFSName                      = "redacted_filename.pptx"
kMDItemFSNodeCount                 = (null)
kMDItemFSOwnerGroupID              = 1896053708
kMDItemFSOwnerUserID               = 397877054
kMDItemFSSize                      = 6564552
kMDItemFSTypeCode                  = ""
kMDItemInterestingDate_Ranking     = 2023-07-19 00:00:00 +0000
kMDItemKind                        = "PowerPoint Presentation (.pptx)"
kMDItemLastUsedDate                = 2023-07-19 12:12:28 +0000
kMDItemLastUsedDate_Ranking        = 2023-07-19 00:00:00 +0000
kMDItemLogicalSize                 = 6564552
kMDItemPhysicalSize                = 6565888
kMDItemUseCount                    = 41
kMDItemUsedDates                   = (
    "2023-01-23 05:00:00 +0000",
    "2023-07-16 04:00:00 +0000",
    "2023-07-19 04:00:00 +0000"
)
kMDItemWhereFroms                  = (
    "redacted url"
)

Re: Rule based on "Date Last Opened" not matching

PostPosted: Tue Jul 25, 2023 8:50 am
by Mr_Noodle
Thanks. I think what is happening is that Apple's APIs are grabbing the first date in the kMDItemUsedDates list. I guess I'll have to not use Apple's code for this and either grab that list manually and grab the last one or grab kMDItemLastUsedDate, which is a singular date.

Can you do mdls on other files to see if the last date in that list or kMDItemLastUsedDate are accurate as well?

Re: Rule based on "Date Last Opened" not matching

PostPosted: Tue Jul 25, 2023 11:48 am
by witchhazel
Mr_Noodle wrote:Thanks. I think what is happening is that Apple's APIs are grabbing the first date in the kMDItemUsedDates list. I guess I'll have to not use Apple's code for this and either grab that list manually and grab the last one or grab kMDItemLastUsedDate, which is a singular date.

Can you do mdls on other files to see if the last date in that list or kMDItemLastUsedDate are accurate as well?


Yes, I've done mdls on other files, and same result - they are showing the correct dates last opened, which is what I see in Finder, but not Hazel.

You may already know this, but if make a change to the file, the Hazel rule works.

Hope this helps.

Re: Rule based on "Date Last Opened" not matching

PostPosted: Wed Jul 26, 2023 8:49 am
by Mr_Noodle
What kind of change are you making? Can you post the mdls and "Get Info" after making a change?

Re: Rule based on "Date Last Opened" not matching

PostPosted: Fri Jul 28, 2023 8:22 am
by witchhazel
Mr_Noodle wrote:What kind of change are you making? Can you post the mdls and "Get Info" after making a change?

I'm not sure what you're asking. Any kind of change within the file/doc changes the "Date Last Opened" date.

Based on some searching and testing, this seems to be a Mac issue. I've tested a bit opening files and and some update, some don't. Some files that are blank for "Date Last Opened" don't even update after opening. One thing that is consistent is when you make changes to the file/doc, the "Date Last Opened" does update. Searching the internet and it seems this is potentially an issue with the DS_Store or something else. I'm sure you can find better information on this than me, but it seems you aren't familiar with this problem, so I thought to share what I found.
https://discussions.apple.com/thread/250087581 / https://discussions.apple.com/thread/252929851

Here are the mdls for a file as an example:
BEFORE
Code: Select all
(base) user@host Downloads % mdls T2C.pptx
_kMDItemDisplayNameWithExtensions = "T2C.pptx"
kMDItemAuthors = (
"Microsoft Office User"
)
kMDItemContentCreationDate = 2023-05-23 18:49:20 +0000
kMDItemContentCreationDate_Ranking = 2023-05-23 00:00:00 +0000
kMDItemContentModificationDate = 2023-05-23 18:49:20 +0000
kMDItemContentType = "org.openxmlformats.presentationml.presentation"
kMDItemContentTypeTree = (
"org.openxmlformats.presentationml.presentation",
"org.openxmlformats.openxml",
"public.data",
"public.item",
"public.presentation",
"public.composite-content",
"public.content"
)
kMDItemDateAdded = 2023-05-23 18:49:20 +0000
kMDItemDisplayName = "T2C.pptx"
kMDItemDocumentIdentifier = 0
kMDItemFSContentChangeDate = 2023-05-23 18:49:20 +0000
kMDItemFSCreationDate = 2023-05-23 18:49:20 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 12
kMDItemFSHasCustomIcon = (null)
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = 1
kMDItemFSLabel = 6
kMDItemFSName = "T2C.pptx"
kMDItemFSNodeCount = (null)
kMDItemFSOwnerGroupID = 1896053708
kMDItemFSOwnerUserID = 397877054
kMDItemFSSize = 12993865
kMDItemFSTypeCode = ""
kMDItemInterestingDate_Ranking = 2023-05-23 00:00:00 +0000
kMDItemKind = "PowerPoint Presentation (.pptx)"
kMDItemLastUsedDate = 2023-05-23 18:49:27 +0000
kMDItemLastUsedDate_Ranking = 2023-05-23 00:00:00 +0000
kMDItemLogicalSize = 12993865
kMDItemPhysicalSize = 12996608
kMDItemTitle = "This template includes"
kMDItemUseCount = 37
kMDItemUsedDates = (
"2023-05-23 04:00:00 +0000“
)
kMDItemUserTags = (
Red
)
kMDLabel_qygkxhrfarhtxanqhi264amkku = 0001-01-01 00:00:00 +0000
(base) user@host Downloads %


AFTER
Code: Select all
(base) user@host Downloads % mdls T2C.pptx
_kMDItemDisplayNameWithExtensions = "T2C.pptx"
kMDItemAuthors = (
"Microsoft Office User"
)
kMDItemContentCreationDate = 2023-05-23 18:49:20 +0000
kMDItemContentCreationDate_Ranking = 2023-05-23 00:00:00 +0000
kMDItemContentModificationDate = 2023-07-28 11:57:58 +0000
kMDItemContentType = "org.openxmlformats.presentationml.presentation"
kMDItemContentTypeTree = (
"org.openxmlformats.presentationml.presentation",
"org.openxmlformats.openxml",
"public.data",
"public.item",
"public.presentation",
"public.composite-content",
"public.content"
)
kMDItemDateAdded = 2023-05-23 18:49:20 +0000
kMDItemDisplayName = "T2C.pptx"
kMDItemDocumentIdentifier = 0
kMDItemFSContentChangeDate = 2023-07-28 11:57:58 +0000
kMDItemFSCreationDate = 2023-05-23 18:49:20 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = (null)
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = (null)
kMDItemFSLabel = 0
kMDItemFSName = "T2C.pptx"
kMDItemFSNodeCount = (null)
kMDItemFSOwnerGroupID = 1896053708
kMDItemFSOwnerUserID = 397877054
kMDItemFSSize = 12993934
kMDItemFSTypeCode = ""
kMDItemInterestingDate_Ranking = 2023-07-28 00:00:00 +0000
kMDItemKind = "PowerPoint Presentation (.pptx)"
kMDItemLastUsedDate = 2023-07-28 11:57:48 +0000
kMDItemLastUsedDate_Ranking = 2023-07-28 00:00:00 +0000
kMDItemLogicalSize = 12993934
kMDItemPhysicalSize = 12996608
kMDItemTitle = "This template includes"
kMDItemUseCount = 42
kMDItemUsedDates = (
"2023-05-23 04:00:00 +0000",
"2023-07-28 04:00:00 +0000“
)
kMDItemUserModifiedDate = (
"2023-07-28 11:57:59 +0000“
)
kMDItemUserModifiedUserHandle = (
397877054
)

Re: Rule based on "Date Last Opened" not matching

PostPosted: Fri Jul 28, 2023 10:14 am
by Mr_Noodle
You mentioned that Hazel works after changing a file; that is what I was asking about. Not all changes are equal as you figured out. I'll still look into the issue of Apple's APIs not returning the most accurate date but yes, it's important to know which apps will actually update the date appropriately.

Re: Rule based on "Date Last Opened" not matching

PostPosted: Fri Jul 28, 2023 10:26 am
by witchhazel
Mr_Noodle wrote:You mentioned that Hazel works after changing a file; that is what I was asking about. Not all changes are equal as you figured out. I'll still look into the issue of Apple's APIs not returning the most accurate date but yes, it's important to know which apps will actually update the date appropriately.

The inconsistency makes it very challenging.