Automator - get or display Spotlight Comments?

I have a workflow to set [or append to] Spotlight Comments, but it would help to show the existing comments first.  How can I get an Automator workflow or application to display the Get Info windows for selected file[s]?  [Or get the comments and put into a variable.]    -Peter
[Using Lion on a MacBook Air]

You can use a Run AppleScript action to get the comment of an input item (e.g. from a selection or choose dialog), which can then be passed to a Set Value of Variable action (the Set Spotlight Comments for Finder Items action will accept a variable in its text field), for example:
on run {input, parameters}
     tell application "Finder" to return comment of first item of input
end run

Similar Messages

  • Spotlight comments not available?

    I've developed an internal website at work that uses PHP, MySQL, Applescript and PDF files to manage the workflow for print projects.
    The basic setup is that a user "publishes" a PDF from InDesign using an Applescript (which ensures the PDF is created with standard settings and file security) and the PDF is copied to the webserver into a folder for review. The applescript then puts the designer's name into the PDF's Spotlight comments.
    Someone reviews the project from a web-page, which looks in the folder and displays thumbnails of its contents. PHP runs an exec() to get the Spotlight comments, and displays the designer's name below the thumbnail, along with the date and time the PDF was "published".
    $PDFcomment = exec("osascript -e 'tell app \"Finder\" to get comment of POSIX file \"$projectsFile/$shortID/$dirShort.pdf\"'");
    The problem I'm running into is that this command is not consistently returning the Spotlight comment. Often the PHP webpage says it's empty, but when I go to the networked volume where these PDFs are stored and Get Info, I can see the correct comment.
    The comment will only appear if I use the Finder on the machine that houses the PDF and Get Info. Subsequent viewings of the PHP webpage then return the correct comment.
    How can I force the Finder to get the current Spotlight comment without having to manually check the file first?
    PowerMac G4   Mac OS X (10.4.5)  

    Running the password reset actually recreated the problem but that's ok because it helped lead me to the true cause and answer. Being a member of the wrong group can cause all sorts of annoying problems e.g. asking for authentication when deleting files, spotlight not indexing some files etc. Luckily this post http://www.macosxhints.com/article.php?story=200711291134001 had the answer. I'll sum it up here:
    I had a problem with spotlight not indexing some files especially spotlight comments. I'd tried deleting spotlight-V100 to re-index and many other things which did not work when all along it was a group membership problem.
    I had upgraded from Tiger to Leopard. The GUI tools in Leopard showed my primary group was staff and nothing looked wrong until I discovered the Unix commands thanks to your great script. I didn't run the script but it was very well commented so I knew what the commands did if I ran them in terminal.
    dscl . read /Groups/staff
    showed I wasn't in the group staff. (even though system preferences>accounts>advanced options said i was!)
    sudo dscl . append /Groups/staff GroupMembership $USER
    added me to group staff.
    sudo chgrp -R staff $HOME
    changes group ownership on all files in home to staff.
    sudo diskutil repairPermissions /
    repair disk permissions.
    Reboot.

  • GET spotlight comments automator?

    I have written an automator, based on a suggestion found at this site, that appends comments to the spotlight comments. I can even delete existing comments. But, what I don't seem to be able to do is to GET EXISTING comments and make a change to these existing comments - add additional comments, if necessary - and enter then new comments back into spotlight comments.
    Does anyone have any ideas?
    Thanks.
    Matt

    Save the code presented below as an application.
    Launch (run) the application to select a file for 'comment' processing; or, drag items onto the applet for each items' 'comment' field to be processed.
    --- Code starts here ---
    on open (ditems)
    repeat with i in ditems -- Cycle through list of dragged items.
    my handle_Item(i) -- Process each item.
    end repeat
    end open
    on run
    my handle_Item(choose file without invisibles) -- Select file to process.
    end run
    on handle_Item(tItem)
    tell application "Finder" to set (comment of tItem) to (text returned) of (display dialog (tItem as string) with title "Spotlight Comment: " default answer (comment of tItem) as string) -- Display and accept modification of 'comment' field contents.
    end handle_Item
    --- Code ends here ---
    To process a file or folder via launching the applet ...
    --- Code starts here ---
    on open (ditems)
    repeat with i in ditems -- Cycle through list of dragged items.
    my handle_Item(i) -- Process each item.
    end repeat
    end open
    on run
    if (((button returned) of (display dialog "Make a selection:" buttons {"Cancel", "File", "Folder"} default button 2)) is "File") then
    my handle_Item(choose file without invisibles) -- Select file to process.
    else
    my handle_Item(choose folder) -- Select folder to process.
    end if
    end run
    on handle_Item(tItem)
    tell application "Finder" to set (comment of tItem) to (text returned) of (display dialog (tItem as string) with title "Spotlight Comment: " default answer (comment of tItem) as string) -- Display and accept modification of 'comment' field contents.
    end handle_Item
    --- Code ends here ---

  • Paste clipboard's contents to selected file's Get Info (Spotlight) comments

    Hi,
    Could someone please help me in building an AppleScript that would paste the clipboard's current contents to the currently selected (in the Finder) file's Get Info (Spotlight) comments?
    I know this can be done with an Automator workflow or Folder Action, but prefer an AppleScript.
    Many thanks!

    The following script will add (a space and then the clipboard) to the comments of the currently selected file. In case there are several items selected it only deals with the first one, and there is also a dialog to edit the final content:
    <pre title="this text can be pasted into the Script Editor" style="font-family: Monaco, 'Courier New', Courier, monospace; font-size: 10px; padding: 5px; width: 720px; color: #000000; background-color: #E0E0E0; overflow: auto">set TheClipboard to (get the clipboard)
    tell application "Finder" to try
    set TheFIle to the first item of (get the selection)
    set TheComment to the comment of TheFIle
    set TheName to text ((length of (path to home folder as text)) + 1) thru -1 of (TheFIle as text)
    if TheName ends with ":" then
    set TheType to " folder "
    else
    set TheType to " file "
    end if
    display dialog ("Change the comment for the" & TheType & return & quoted form of TheName & "?") with title "Edit Spotlight Comment" default answer (TheComment & space & TheClipboard)
    set comment of TheFIle to text returned of the result
    end try
    </pre>

  • Automator for Exporting Spotlight Comments?

    Hello,
    I have around 700 historic photos that have been digitized. All the photo details (dates, etc.) were entered into the Spotlight Comments field under Get Info. Unfortunately, none of the comments appear when I open the photos in Adobe Bridge CS4. Is there an easy solution (perhaps an Automator script) to export the Spotlight Comments and use them elsewhere?
    Thank you,
    Brian

    Brian
    If I read you right, what you are trying to do is grab Finder metadata and convert it to photo metadata. Specifically, convert spotlight comments to Exif and IPTC - which is what a Photo app will need.
    You can't do this with Automator. The Automator dictionary has ways to set Spotlight Comments but I can see no way to get them. Further the dictionary has the ability to write to the IPTC data only of images in Aperture, not in the Finder or iPhoto.
    You might do better with that question on the Automator forum here:
    http://discussions.apple.com/forum.jspa?forumID=1261
    Have you tried the Applescript that was suggested when you posted the query last?
    As your target are file managed by Bridge, give the Adobe forums a go too.
    However, you may run into another issue here and that is that most scanners (as I presume this is how the photos were digitised) do not create Exif and IPTC data for scanned images. It may not be possible to do what you want to do.
    Regards
    TD

  • Automator doubling my Spotlight comment text

    I made a simple workflow to add text to the Spotlight comments field using "Get Selected Finder Items" and "Set Spotlight Comments for Finder Items" but when I use it, the text I enter is entered twice in the Spotlight field. What am I doing wrong here or is this a bug?
    Thanks,
    Edward

    Are those the only actions in the workflow? If you are doing something like using this as a Service, the workflow is automatically passed the selected items, so adding another action to get the selection will double up the items.
    Also note that this is the Tiger Automator forum - Automator in *Snow Leopard* is quite a bit different, so future questions should be posted in the Snow Leopard forum.

  • Automator 2-Add Spotlight Comments still dead?

    After the latest update, I was hoping that this Action would have been fixed. When creating a Workflow, adding Spotlight Comments works fine. However, save as a plugin or application and its dead.
    Is it me, or is this still a bug after the latest update?

    I use this more than any other Action because my entire Archive is rooted in the Spotlight reference process.
    I was given a possibility in another post to not use "Get Selected Finder Items" and then it would work. Which, to me, is counter to proper usage, especially in regard to how it worked in Automator 1. So I am considering this a "bug" in Automator until they fix it.

  • Automator Folder Action: File Name = Spotlight Comment?

    Hey guys,
    I'm trying to have automator add the original filename of a file as spotlight comment when it is added to a certain folder. I can only use the "Set Spotlight Comments for Finder Items" in folder actions to add a specified comment, but nothing else. Is it possible to grab the file name via applescript?
    The idea behind this is to preserve the original file names of all downloaded files before they get renamed.
    Thanks,
    V

    Thanks for your reply, I now have your action installed and it does get the filenames, but I still can't add them to the spotlight comment text box. Looks like I didn't think this through properly.

  • "Spotlight Comments" in Finder Get Info window doesn't accept Clipboard contents

    I wanted to paste caption and credit info from a NASA video download into the file's Spotlight Comments in the Get Info window. Done it in the past no problemo. Today it doesn't work.
    Tried pasting the copied web page content to TextEdit and converting to plain text, copy again, paste still a no-go. Tried typing in the Spotlight Comments window, that works ok. Looked at the contents of the Clipboard and the text appears there, labeled either as rtf or text depending on where the text was pasted from (web or TextEdit).
    Tried copying a couple of letters from the converted text, and they pasted ok into Spotlight Comments.
    Suggestions to make the Clipboard contents paste?
    Thanks.

    On further inspection, it appears that the contents of the old Comments field are carried forward into the Spotlight Comments field.

  • Spotlight Comments No Showing Up in Get Info

    I moved thousands of video files to new folders (Drag & Drop Method). Now the spotlight comments for the files are no longer showing up in the get info window. I'm devastated because the comments contained critical information about the video. Without the comments, the organization of the files is a mess. I have no idea how to fix this problem.

    ok, this shows that the spotlight comment "the Kat" is retained in spotlight database as it's recorded in the kMDItemFinderComment field. then the problem is likely corruption of the .DS_store files for the folders containing those files. I really don't know why this happens and what's the proper way of dealing with this but I made the following workaround for the same problem while helping someone else in the past
    http://discussions.apple.com/thread.jspa?messageID=10549447
    paste the following into AppleScript Editor
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #ADD8E6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    tell application "Finder"
    set mlist to selection
    set curfolder to item 1 of mlist
    repeat with this_item in entire contents of curfolder
    set ppath to quoted form of POSIX path of (this_item as alias)
    set comment of this_item to (do shell script "mdls -name kMDItemFinderComment " & ppath & "| awk -F\\\"  '{print $2}'") 
    end repeat
    end tell</pre>
    select the folder containing all those items (they can be in subfolders) and press 'run" in applescript editor.
    Message was edited by: V.K.

  • Need help modifying Applescript to copy "Spotlight Comments" into file

    Hello all,
    I have a very large batch of images of Leonardo da Vinci's notebooks. I used the "Spotlight Comments" field of each file to save information about the notebook page depicted in each image:
    Well, I had to modify each image in Photoshop and when I saved the files, Photoshop of course didn't retain the Spotlight Comments. Now, before I modified the images, I duplicated the directory, so I have a copy of all of the images that retain their Spotlight Comments field with each image's information. What I want to do is copy the text from the Spotlight Comments field of the original files and either paste this text into the Spotlight Comments field of the modified files (which are in a different directory, but retain the same filenames as the originals), or at least copy the text from the Spotlight Comments field of the original files and paste each block of text into a txt file with a couple of blank lines in between each entry, so that I can manually copy/paste the citations into the modified image's Spotlight Comments fields.
    I successfully used this Applescript:  https://discussions.apple.com/message/6741062#6741062
    to get the Spotlight Comments from the original files, but it displays them one by one in pop-up dialog boxes and because I have almost a thousand images it is extraordinarily wearisome to copy the text from each pop-up, paste it into a text file, make two blank lines, click "OK" in the pop-up to get the next one...
    Can anyone suggest how I can modify the code I have to tell the Finder to copy the contents of each pop-up and paste them into a single text file with a couple of blank lines between each entry?
    I have the barest, most rudimentary knowledge of Applescript, which is why I'm asking if one of the wizards here can help me modify or write an Applescript to do what I need to do.
    Thank you so much!
    BTW, here is the code from the aforementioned discussion that gets the Spotlight Comments from files. I made into an Applescript application using Automator:
    tell application "Finder"
    repeat with tItem in input
    set (comment of tItem) to (text returned) of (display dialog "Spotlight Comment: " default answer (comment of tItem as string))
    end repeat
    end tell

    Hi,
    Evan Izer wrote:
    Now, before I modified the images, I duplicated the directory, so I have a copy of all of the images that retain their Spotlight Comments field with each image's information. What I want to do is copy the text from the Spotlight Comments field of the original files and either paste this text into the Spotlight Comments field of the modified files (which are in a different directory, but retain the same filenames as the originals)
    This script does exactly that:
    set sFolder to (choose folder "Select folder wich contains original images.") as string
    set dFolder to choose folder "Select folder wich contains modified images."
    tell application "Finder"
          repeat with tItem in (get document files of dFolder)
                set origFile to sFolder & (get name of tItem)
                if file origFile exists then
                      set origComment to comment of file origFile
                      set comment of tItem to origComment
                end if
          end repeat
    end tell

  • Automate Spotlight Comments

    I'm very new to this stuff but I've been messing with an Automator action to tag files with a Spotlight Comment as a Service. I want be able to select a folder and then have it ask me for text which it then saves as a Spotlight comment to all the files I've selected. Seems really easy. But I can't get it to work. I must be missing a step.
    Here's what I have...
    1. Get Folder contents (or I've tried get specific Finder items as a test.)
    2. Ask for Text.
    3. Set Value of Variable (which I've called Tag).
    4. Set Spotlight Comments for Finder Items (with my variable, Tag, dragged into the Text area.)
    I cannot get this to work. I get an error of The action "Set Spotlight Comments for Finder Items" was not supplied with the required data.
    I've also tried inserting a "Get value of variable" after the Set Variable. That doesn't work either. I get an erro of NSCFArray intiWithObjects:count:}: attempt to insert nil object at objects [0].
    One clue would be that when the ask for text dialogue opens, it's already filled in with the pathname of the file.
    I'm sure this is a piece of cake for someone to explain to me as to why it doesn't work.
    Thanks,
    Jeff

    I don't know how to accomplish this in Automator and will be interested in knowing the solution, but in AppleScript you can go about it like this
    1. Get Folder contents (or I've tried get specific Finder items as a test.)
    set aFile to (choose file without invisibles) as alias
    -- Add 'with multiple selections allowed' if you want to do this for multiple files
    --but then the rest of the code has to be changed as well
    2. Ask for Text.
    3. Set Value of Variable (which I've called Tag).
    set theComment to text returned of (display dialog ("Enter comment for" & return & (aFile as string)) default answer "")
    4. Set Spotlight Comments for Finder Items (with my variable, Tag, dragged into the Text area.)
    tell application "Finder" to set comment of aFile to theComment

  • Importing Spotlight Comments

    Hi Everyone,
    I have around 700 historic photos that have been digitized. All the photo details (dates, etc.) were entered into the Spotlight Comments field under Get Info. Unfortunately, none of the comments appear when I open the photos in Adobe Bridge CS4. I will now start using Bridge to add the metadata tags.  However, is there an easy solution (perhaps an Automator script) to export the Spotlight Comments and use them in Bridge?  I really don't want to retype the information, and I would be extremely grateful for any advice.
    Thank you,
    Brian

    You most probably require the help of script to do this. Better to ask your Question in that forum. Your Spotlight Comments belong to Finder both AppleScript & Shell can get access to these not too sure about JavaScript. JavaScript would be required to add this info to the correct files.

  • How to copy a files name and spotlight comments to a text file for an entire folder

    I have movie covers saved as a jpeg for every movie my family and I own. There is about 700 and they each have a comment of the main actors, release dates, and descriptions. This makes it easy to find what to watch. I want my parents to have all of this info but they have a windows laptop so the comments don't transfer with the file and can't be searched like you can on a mac. Is there an applescript, automator, program I can download,  or program code supported in xcode that will do at least one of the following things?
    1)Take the name of the picture file and spotlight comment, copy and paste it into a text document like word that looks like this...
    File Name1- Spotlight Comment for file 1
    File Name 2- Spotlight Comment for file 2
    . for all 700 files in a folder
    2) It would be equally helpful if there was something that would take the name of the picture file and spotlight comment, copy and paste it to a movie file's comments with the same name but obviously has different extention. For an example
    In a Pictures folder
    Name: Dark Knight, The.jpeg       Comment: (2008) Genre: Action...             <- copy comment
    In a Movie Folder
    Name: Dark Knight, The.m4v       Comment:                                               <- paste 
    and do this for all 700 files
    3) Is there a free photo program that works on mac and windows that I can put all my movie pictures in and have a description like I did with the comments? It would also need a place that to search the description for keywords. So Basically an itunes for pictures that works on both mac and windows. If so I still need a way to get the spotlight comments to the description.
    4) I feel like this would make things more difficult, but if not I can put all of the .m4v files in itunes so instead of pasting all the comments back into a file in finder paste them in a description in itunes
    5) At the very least a code that I can run one by one for every file that will paste the comments into the same document
    Note: When I say spotlight comments I mean the comment box that is available when you click on get info of a file. The pictures are in the pictures section of finder in a folder called Movie Pictures. The movie files are on an external hard-drive in a file called Movies. Also I am slightly familiar with applescript and automater in that I have used both to create keyboard shortcuts and simple voice commands. I have programmed in c++ and C too. So If you give me a code for applescript I do know what to do with it.
    Thanks to anyone who takes the time to read all of this and extra thanks to anyone who tries to help.

    Clendenen02 wrote:
    2) It would be equally helpful if there was something that would take the name of the picture file and spotlight comment, copy and paste it to a movie file's comments with the same name but obviously has different extention. For an example
    In a Pictures folder
    Name: Dark Knight, The.jpeg       Comment: (2008) Genre: Action...             <- copy comment
    In a Movie Folder
    Name: Dark Knight, The.m4v       Comment:                                               <- paste 
    and do this for all 700 files
    This Bash script will do it.
    Edit "PicDir" and "MovDir" to the location of your Folders
    (Note: The comment is written to the m4v file using xattr, so the Spotlight comment field appears blank in Finder, but the comment metadata is still indexed by Spotlight (If you add a Spotlight comment from Finder, it is stored both as an extended attribute and in a .DS_Store file)
    #!/bin/bash
    PicDir=$HOME/Desktop/Pictures
    MovDir=$HOME/Desktop/Movies
    for f in $PicDir/*
    do
         if [ ! -d "$f" -a "${f##*.}" == "jpeg" ]; then
              comment=$(mdls -raw -name kMDItemFinderComment "$f")
              if [[ $comment != "(null)" ]]; then
                   picname=${f##*/}
                   movname=${picname%.*}.m4v
                   if [ -e "$MovDir"/$movname ]; then
                         xattr -w com.apple.metadata:kMDItemFinderComment "\"$comment\"" "$MovDir"/$movname
                   fi
              fi
         fi
    done

  • Problem with add Spotlight Comments script.

    Hello,
    I am trying to add Spotlight Comments to some files using Automator. I have made an very simple script in Automator that add Spotlight Comments to the files that I have selected in Finder. I save this script as an app and it work great. I also save the same script but not as an app but as a service. The problem here is that when I run the service it add the same Spotlight Comment two times. For example, if I add "@Webshots" with the app the Spotlight Comments of the files is "@Webshots" but when I do it with the service the Spotlight Comments of the files is "@Webshots" "@Webshots". Can anybody help me with this? I will appreciate it a lot any help that you could give me. Thanks

    I suspect your workflow includes 'get select finder items' as the first action. get rid of it. it's redundant in a service that accepts files and folder in finder. that's why everything happens twice.

Maybe you are looking for

  • I-pod cannot update because all the playlists selected for no longer exsist

    What does this mean?? I have tons of songs on my itunes, but now I have 0 on my ipod and can't figure out how to transfer them. THis is a new problem, they used to transfer just fine...HELP

  • Credit block on over due

    Dear Gurus, There are different payments terms, which are assigned based on divisions in the customer masters.  for example: 001-    10 days credit from delivery date. (division-10) 002-    20 days credit from delivery date. (division-20) The issue i

  • Word and Pages-files cannot be viewed on iPhone

    I have experienced that I cannot upload a word-file (.doc) or Pages 09 and view it on my iphone. i have tried both mail and air sharing neither work. iPhone knows the type of doc, so that's not the problem. Any hints or is it due to the new software?

  • Standard report center text in table

    Hello, I am new to LabVIEW 2011 running Windows 7.  I am trying to run and print standard report in LabVIEW but I couldn't figure out how to make text or data to center in the table. See pic below. Please help. Thank you so much in advance. Marlin12

  • Dealing with User Defined Tables with the DI Server

    I have a general question about the best way of working with the data in user defined tables using the DI Server. It appears from previous posts that it is not possible to use the standard methods such as UpdateObject. Also since update/insert and de