Moving a File Using KM Deletes the File Comments

I noticed when i have a comment made on a file in the "Comments" field, it gets lost when i use the Move File Action.

This is the initial situation:

Then after a Move File Action

i get this:

Notice that the Comments: "1 Jul 2019" disappeared.

Intended behaviour?

1 Like

It is not the intended behaviour, but unfortunately it appears to be a bug in the system, since the move command in Keyboard Maestro is a straight API call:

[fileManager moveItemAtPath:source toPath:destination error:&error];

The system file manager moves the file, so I'm afraid there is nothing I can do to resolve this.

I believe comments are stored in an external (to the file) database, and indeed if you set the comment to something new after the move, and then move the file back it will actually restore the comment to the original value (which sounds like a bit of a security hole to me).

My guess would be this is a consequence of the move from HFS to APFS, but it could be a different style of bug.

1 Like

Apparently comments are (inexplicably) stored in the .DS_Store file in the folder, which the Finder maintains and apparently nothing else knows about.

Which is a shame, since comments should be a valuable and important piece of user data, and they have never been reliable in the entire time of their existence.

I think they are stored in the .DS_Store file and in the extended attributes of the file. At least when the comment was created with the Finder.

With xattr -l <file> you can see the comment of a file.

See also here:

Maybe the folks at binarynights have encountered similar issues, but then the problem already was there before APFS has appeared.

Hey @Fokke,

If you script the Finder with AppleScript you should retain the comments.

I haven't explicitly tested beyond macOS 10.12.6 (Sierra) though.


True. Using AS it works.

Also very "interesting'; when these file are in the iCloud folder the comments are only visible on the computer on which they are made. Which underlines the findings of Tom that they are in fact in the ".DS_Store file and in the extended attributes of the file".

It's irritating though... i had a plan with it that have to think over again.

If “properly copied” via Finder (or AS via ‘tell Finder’ of course), the comments are in both the .DS_Store file and in the xattr. Easy to check.

But there seem to be different APIs and none of them – apparently– provides a Finder-like behavior. Not the one used by @peternlewis, and not he one used by bynarynights.

Even if i don't copy the files at all; adding a Comment to a file in a iCloud folder shows the Comment only on th computer that added the Comment. Another computer logged in on the same iCloud account, sees the same files but without the comments. Adding a Comment on that other computer has no effect on the other computers too.

iCloud syncing is not done by the Finder, as far as I know. There are a couple of background processes responsible for that (bird and/or cloudd, maybe a third one, not sure).

On my machines, a comment does get synced in its form as extended attribute (though not properly updated after changing the comment, but maybe this just takes a couple of days :disappointed:).

But the comment as extended attribute alone doesn’t seem to be enough for the Finder to display it. My guess is that iCloud does not sync the .DS_Store file, and hence no comment displayed in the Finder on the machine where iCloud synced to. (To verify later.)