How Do I Get a Finder Comment From a Local or Remote Folder?

Hi everyone!

I have a problem today with the "Get file attribute" action.
I can't set the comment of a folder to a variable with "Get comment".
If I change the action to "Get tags", it immediately gets the correct tags. But tags are cumbersome and I would prefer to use comments so that the according actions are invisible to the user, yet useful for the macro.

And what's even more strange is that if I use a "Set comment" action, that said action sees nothing as current comment for the folder, but if I hit Try, the comment written in the action indeed goes into the comments section of the specified folder. You can see that in the screenshot below:
Capture d’écran 2021-02-16 à 20.05.25

So to recap, I can't see the comment of a folder, but I can change it. I need to be able to read and write the comments section of folders, and not write only.
Could anyone tell me where I'm doing things wrong? :slight_smile:

Thanks in advance,

Okay, so I've done some more testing and I tried the mdls command line tool.

While it can read a comment from a file on the internal disk, it cannot read comments from a file or folder on a network volume.

Is that a clue?

Hey Charles,

In future please post the smallest possible test-case macro and all related files and/or images that illustrate your problem. This is easy to do using the Keyboard Maestro Editor's Share-to-Forum command, although it takes a couple of practice runs to get used to how it works.

You can zip and drag and drop any additional items into the forum editor.

How to Post Your Macro to the Forum

Trying to recreate what you've done is hit or miss at best, and most folks won't bother. The easier you make it to test your work, the more likely you'll get quality help.

A) Keyboard Maestro doesn't always populate result fields the way you think it should or when you think it should.

B) Sometimes people forget to “Try” their Set-Variable-To action(s) to initialize values.

C) It's generally good practice to test your macros using a known trigger and reserve “Try” for items you know it works with.

I'm not sure what's going on with your macro, but my test macro (appended) works fine with both local and remote folders.

Give it a try:

  • Remember to change all the paths appropriate to your set-up.
  • Remember that imported macros are disabled, and you have to enable the macro or the macro-group it's in depending upon the circumstances.

If my macro doesn't work for you please be sure to post the version of macOS you're using.

Oh, yeah – mdls works fine with my remote folder:

mdls -name kMDItemFinderComment '/Volumes/User_Name/Downloads/JunkMe!/'

You have to have Spotlight indexing enabled for that volume though.


TEST ⇢ Get-Set an Item's Finder Comment v1.00.kmmacros (8.0 KB)

1 Like

Hi Chris!

Thank you so much for your answer and for sharing the appropriate way to post here, I'll see to it in the future :slight_smile:

The problem was Spotlight indexation, it is now solved!

1 Like