Skip to content

Instantly share code, notes, and snippets.

@matthewmccullough
Created January 25, 2010 06:23
Show Gist options
  • Save matthewmccullough/285667 to your computer and use it in GitHub Desktop.
Save matthewmccullough/285667 to your computer and use it in GitHub Desktop.
tell application "Finder"
activate
set these_items to the selection
log these_items
repeat with this_item in these_items
set item_name to (get displayed name of this_item)
if item_name is not ".DS_Store" then
set current_com to (get comment of this_item)
if current_com is not "" then
set comment of this_item to current_com as string
end if
end if
end repeat
end tell
@aminimalanimal
Copy link

Hi there!

After spending my entire day (11 hours so far... eep.) attempting to figure out why Finder suddenly lost all of my comments, I finally stumbled upon an article that you wrote relating to this script.

What you describe in the article is exactly what I decided to attempt to do, and outlines the issue better than anywhere else I've seen in my research today: get the extended attribute metadata value and apply it back to the Finder item.

Unfortunately, this script doesn't work for me—I can see in the Script Editor log that get comment is returning an empty string for my items. I can see in Terminal that the data is still present with xattr -pl com.apple.metadata:kMDItemFinderComment [path_to_file], but mdls -name kMDItemFinderComment (as another Applescript and a few other Terminal suggestions pointed out) only returns null for these items. I believe that mdls is referencing the .DS_Store, so that makes sense.

Do you have any idea how to slightly tweak it so that it references the extended attribute metadata? It is so so close, but I can only assume that this too is referencing the .DS_Store rather than the metadata. I am on OS X 10.10 Yosemite now, so perhaps something under the hood has changed since 2010.

@ppseprus
Copy link

Hey there,
Could you find a solution for this?
I was trying to.. sort of set Finder windows back to default, but I forgot about the Spotlight Comments, and I deleted the .DS_store files
I may not be an expert, but tell application "Finder" and get comment would only use the comments stored in the .DS_store files, which are deleted now. We cannot access the extended attributes through tell application "Finder".
Or can we?
Did you solve it eventually?
Thanks,
ppseprus

@am1no
Copy link

am1no commented Jun 9, 2017

Great idea!
Tell me, how can this not only be easy to receive a comment, but also change it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment