'Unable to overwrite kMDItemLastUsedDate mac os xattr
I would like to overwrite the "kMDItemLastUsedDate" from a mac folder, reading online it does not seem to work with touch so I tried a few things with xattr.
here is when I get the following command (to get metadata info):
$mdls Test2
_kMDItemDisplayNameWithExtensions = "Test2"
kMDItemContentCreationDate = 2022-04-20 12:16:27 +0000
kMDItemContentCreationDate_Ranking = 2022-04-20 00:00:00 +0000
kMDItemContentModificationDate = 2022-04-20 12:16:27 +0000
kMDItemContentModificationDate_Ranking = 2022-04-20 00:00:00 +0000
kMDItemContentType = "public.folder"
kMDItemContentTypeTree = (
"public.folder",
"public.directory",
"public.item"
) kMDItemDateAdded = 2022-04-20 12:16:27 +0000
kMDItemDateAdded_Ranking = 2022-04-20 00:00:00 +0000
kMDItemDisplayName = "Test2"
kMDItemDocumentIdentifier = 0
kMDItemFSContentChangeDate = 2022-04-20 12:16:27 +0000
kMDItemFSCreationDate = 2022-04-20 12:16:27 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = (null)
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = (null)
kMDItemFSLabel = 0
kMDItemFSName = "Test2"
kMDItemFSNodeCount = 0
kMDItemFSOwnerGroupID = 20
kMDItemFSOwnerUserID = 501
kMDItemFSSize = (null)
kMDItemFSTypeCode = ""
kMDItemInterestingDate_Ranking = 2022-04-20 00:00:00 +0000
kMDItemKind = "Folder"
kMDItemLastUsedDate = 2022-04-20 12:24:52 +0000
>>kMDItemLastUsedDate_Ranking = 2022-04-20 00:00:00 +0000
kMDItemUseCount = 1
kMDItemUsedDates = (
"2022-04-19 22:00:00 +0000"
)
Then I if I run:
$xattr -w "com.apple.metadata:kMDItemLastUsedDate" "2022-03-10 12:16:27 +0000" Test2 Then I get:
$xattr -l Test2
com.apple.metadata:kMDItemLastUsedDate: 2022-03-10 12:16:27 +0000
This metadata seem not to have changed neither in the finder nor in the mdls
$mdls Test2
_kMDItemDisplayNameWithExtensions = "Test2"
kMDItemContentCreationDate = 2022-04-20 12:16:27 +0000
kMDItemContentCreationDate_Ranking = 2022-04-20 00:00:00 +0000
kMDItemContentModificationDate = 2022-04-20 12:16:27 +0000
kMDItemContentModificationDate_Ranking = 2022-04-20 00:00:00 +0000
kMDItemContentType = "public.folder"
kMDItemContentTypeTree = (
"public.folder",
"public.directory",
"public.item"
)
kMDItemDateAdded = 2022-04-20 12:16:27 +0000
kMDItemDateAdded_Ranking = 2022-04-20 00:00:00 +0000
kMDItemDisplayName = "Test2"
kMDItemDocumentIdentifier = 0
kMDItemFSContentChangeDate = 2022-04-20 12:16:27 +0000
kMDItemFSCreationDate = 2022-04-20 12:16:27 +0000
kMDItemFSCreatorCode = ""
kMDItemFSFinderFlags = 0
kMDItemFSHasCustomIcon = (null)
kMDItemFSInvisible = 0
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = (null)
kMDItemFSLabel = 0
kMDItemFSName = "Test2"
kMDItemFSNodeCount = 0
kMDItemFSOwnerGroupID = 20
kMDItemFSOwnerUserID = 501
kMDItemFSSize = (null)
kMDItemFSTypeCode = ""
kMDItemInterestingDate_Ranking = 2022-04-20 00:00:00 +0000
kMDItemKind = "Folder"
kMDItemLastUsedDate = 2022-04-20 12:24:52 +0000
kMDItemLastUsedDate_Ranking = 2022-04-20 00:00:00 +0000
kMDItemUseCount = 1
kMDItemUsedDates = (
"2022-04-19 22:00:00 +0000"
)
This is my interrogation number 1.
Then if I try to delete the newly added metadata with:
$xattr -d com.apple.metadata:kMDItemLastUsedDate Test2
The first time it works and disappears when I do xattr -l Test2
But it doesn't work a second-time and doesn't disappear from mdls
xattr: Test2: No such xattr: com.apple.metadata:kMDItemLastUsedDate
-> my conclusion is that the "com.apple.metadata:metadata:kMDItemLastUsedDate" is not the one that I see in mdls, but and extra metadata that I add with xattr -w.
Any idea on how to modify the kMDItemLastUsedDate?
Cheers.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
