I'm trying to set the values of some file metadata attributes in OS X Yosemite - kMDItemDateAdded
and kMDItemLastUsedDate
- the values of which can be shown using mdls <filename>
. I'm trying to set their values using xattr
.
I've tried this:
xattr -w com.apple.metadata:kMDItemDateAdded "2001-01-01 12:34:56 +0000" some_file.txt
xattr -w com.apple.metadata:kMDItemLastUsedDate "2001-01-01 12:34:56 +0000" some_file.txt
I've tried this:
xattr -w kMDItemDateAdded "2011-01-01 12:34:56 +0000" some_file.txt
xattr -w kMDItemLastUsedDate "2011-01-01 12:34:56 +0000" some_file.txt
...but have had no success. xattr
reports no errors, but the file metadata attribute values are left unchanged.
Do you know if what I'm trying to do is possible, and if it is, where I'm going wrong?
xattr -l some_file.txt
to look at the values after changing them? And no, I don't have an explanation for this.xattr -l some_file.txt
, before and after executing the four commands listed in my question above. Before executing the commands, the attributescom.apple.metadata:kMDItemDateAdded
,com.apple.metadata:kMDItemLastUsedDate
,kMDItemDateAdded
,kMDItemLastUsedDate
aren't listed. After executing the commands, they are.kMDItemDateAdded
andkMDItemLastUsedDate
, shown usingmdls <filename>
, are unchanged. Could it be, that the four commands listed in my question above create new attributes (shown usingxattr -l some_file.txt
), and thatmdls <filename>
gets its attribute values from elsewhere?