Add Selected Text to Finder Comments of the File Most Recently Added to Desktop

In a nutshell, here's what I wish to do:

  1. I manually select a portion of a URL in a web browser
  2. A hotkey copies my selection, then launches Finder's info Info Inspector for the file I've most-recently added to my desktop (i.e., a screenshot).
  3. Paste the contents of the selected text into the Comments box.

That's it, basically.

I want the Info Inspector (Command + I) however to actually display, to allow me to evaluate the pasted contents before I close that window.

Suggested workflow for setting this up would be most appreciated. Thanks in advance!


Hey Ryan,

This macro should fulfill your requirements.

It displays the new comment in a KM text window, but you can enable the AppleScript action to reveal the file in the Finder. From there type I.


Add a Comment To Most Recent File on the Desktop v1.00.kmmacros (10 KB)

Macro Image

Keyboard Maestro Export

You are amazing! Thanks a ton, Chris! :pray:

Will give it a whirl in the morning. (Busy day, sorry for delay responding!)


1 Like


Chris, again, I can't thank you enough for the guidance on this. Much appreciated!

Getting some snags with and without the AppleScript:

scr 2023-01-19 at 12.05.30 PM

scr 2023-01-19 at 11.56.07 AM

Curious about the first action after "Copy." I'll have to do my due diligence by learning what local_URL refers to here. Just wish to point out, or clarify, that my goal here is to not copy an entire URL from a browser tab, but rather, just a part of one.

Said another way, I think "URL" can be forgotten about, as all we're really doing here, is copying text from one place, and pasting it to another. Another clarification: end-goal is for the contents in the comments box, in Finder, to be plain text and nothing more.

End destination for files that get the treatment of this macro, is DEVONthink. When the same files get transfered to there, manually, I run a subsequent script that converts the contents in Finder's comment of those files, to the URL field for same, in DT.

Once we get this running, I'll show a practical use-case for this macro, which I think might have widespread appeal, even without DT, for academics/researchers/genealogists etc.

Thanks again for helping!

P.S. Running Big Sur 11.7.2, because my computer is a clunker. Its ten-year anniversary is next month. Once I hit that milestone this old clunker goes out to pasture, and I'm upgrading :grin:.

Are you using the macro as is, or did you change it any?

No changes. Ran it as-is.


You do have a file on the Desktop – yes?

Setting a local variable to the system clipboard for later use.

That's what the copy action does – but of course you're responsible for selecting the text to be copied.

It helps to actually know what you're talking about... :sunglasses:

Something is obviously quite out of whack – I'll think it over and post a diagnostic macro sometime after lunch.

1 Like

Thanks so much. Been playing with this right now actually. Tried adding some pauses, unchecking reverse, etc. No dice as of yet. Indeed, plenty of screenshots on Desktop, as most recent files, for testing this.

FWIW, files added to my Desktop have default permissions as follow: my "account" ("computer-name") show privilege as "Read & Write." But below that are two more; one labeled staff and another everyone (neither of which I created). These latter two default to "Read only."

Edit: also should add: the awesome display text box you added (which is fine for my needs), shows with blank contents.

Wild stab -- you aren't, by any chance, using iCloud-shared Desktop and Documents folders? That can create "interesting" things when resolving paths to those locations...

1 Like

Okay, first diagnostic macro.

  • Run the macro.
  • Post the results.

Download: Add a Comment To Most Recent File on the Desktop Diagnostic v1.00.kmmacros (9.8 KB)

Macro Image

Keyboard Maestro Export

@ccstone Super sorry for delay! Finally have my head above water--was swamped past two days. Looking very forward to begin testing/tackling this in an hour or two. Thanks again for all the help. Very much appreciated!

you aren't, by any chance, using iCloud-shared Desktop and Documents folders?

Much appreciated suggestion! This was turned off, but I tried this feature some years ago. Good tip!

The text box is brilliant! Still running amok, but finally have two days away from the office. Will tinker. I think by your design, your updated version does not kick out the error notifications. Clearly the text contents are getting to the clipboard and being revealed, but writing/pasting same to the intended destination isn't working.

Video of workflow (firing this with the Option+1 hotkey arrangement you created).

I have all applications turned off except Chrome and KM, to include apps other than KM that would normally run in the background, i.e. Backblaze, Google Drive, Carbon Copy Cloner and one or two others.

Hey Ryan,

  1. You do have files on your Desktop – yes?
  2. You're not in some space where there're no files on the Desktop – right?
  3. What version of macOS are you using?
  4. What do you get if you run this from Apple's Script
set AppleScript's text item delimiters to linefeed
tell application "Finder"
   return files of desktop as text
end tell


Hi Chris,

  1. I have contents on my Desktop in the form of many screenshots (that save to there by default).
  2. I don't use Spaces but this presents an interesting theory.
  3. 11.7.2 (Big Sur)
  4. The script lists all documents currently on the Desktop:
Macintosh HD:Users:[my username]:Desktop:[filename]

Me thinks something is wonky with disk permissions. I ran OnyX last night, but result of that effort was fruitless. Disk permissions were verified without errors. I then visited System Preferences > Accessibility > Security & Privacy > Privacy and made sure KM and Finder had Full Disk Access.

Of course, there's an ugly way of making this automation concept work. The one I'm thinking of would call-up the Info Inspector, then use "found image" and x/y pixels to position a pointer in the comments box.

Plan-B, is to just hang tight for a month or so, when I buy a new computer. When I do, I'm giving serious consideration to trying something I've never done before, by using a freshly installed OS without any files or content, then populating the new machine with my goods manually, in a onsey-twosey sort of way. I've been a Mac guy since 2007, but every computer I've bought in the past was set up by using either Carbon Copy Cloner or a Time Machine drive. I think it's time to start anew as it's been 16 years.

Well, there certainly is something weird going on with your system...

Run this (Diagnostic Macro 2), and let me know what you get.

Add a Comment To Most Recent File on the Desktop Diagnostic v2.00.kmmacros (9.4 KB)

Macro Image

Keyboard Maestro Export