Set Spotlight Comment if Blank

I would like to add spotlight comments to a number of files but only if they do not contain a comment already. I'm using Get Specified Finder Items as the input. I thought I could use the Filter Finder Items action to filter on blank spotlight comments but the action doesn't allow this. I can't see where or how to specify the condition. It should be simple but I'm missing something. Thank you!

You can use a Run AppleScript action for the filter - for example:
1) Get Specified Finder Items
2) Run AppleScript:
<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: #FFEE80;
overflow: auto;"
title="this text can be pasted into an Automator 'Run AppleScript' action">
on run {input, parameters}
return items that do not have Spotlight comments
input: a list of Finder items to filter
output: a list of items that do not have Spotlight comments
set output to {}
repeat with AnItem in the input
tell application "Finder" to get the comment of AnItem
if the result is "" then set the end of the output to (AnItem as alias)
end repeat
return the output -- pass the result(s) to the next action
end run
</pre>
3) Set Spotlight Comments for Finder Items

Similar Messages

  • Ask for Text for Set Spotlight Comments for Finder Items

    I want the text from the "Ask for Text" to go in to the "Set Spotlight Comments for Finder Items" action, but they don't seem to interact.
    Any ideas?

    first you make a new variable using variables tab. then you add the action "set value of variable" right after the action ask for text. drag the variable you made to the variable field of that action. this will set the value of that variable to the output of the previous action.

  • Setting Spotlight Comments For Multiple Files?

    In iTunes and iPhoto, you can quickly assign "Comments" or "Keywords" to multiple files, all at the same time. Is there a way to do this in Spotlight? I'd like to add the same Spot Comment for 10 files. I tried selecting all 10 files, and clicking Get Info, but this flooded my screen with 10 individual Info windows!

    Rueben
    Check out SmartComments or This Automator Action
    Regards
    TD
    MacBook Pro 15 2.16gig / iMac 20" 2.16 C2D   Mac OS X (10.4)   2 gig RAM/ 2 gig RAM

  • 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

  • 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

  • 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 - 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

  • 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.

  • Add Spotlight Comment from file?

    As I understand the way the *Add Spotlight Comments* works, the input is the file (or set of files) to be modified, and the added comments can either come statically from the workflow, or as user input if the workflow permits *Show Action When Run*.
    I have a moderately ugly shell script that downloads and examines a succession of files and builds a description (just a few dozen words) that I want to add automatically to those comments. At the end of my script, I've downloaded the file, and stored the comments I want in a separate temp file.
    As far as I can see, Automator can't do this: I can't specify a file as the incoming source of those new Spotlight Comments, can I?
    Assuming the answer is negative, two quick non-Automator followups:
    1) Is there any shell-script level Unix command that can manipulate the comments (without trying to hack into the .DS_Store files, that is).
    2) Can Applescript do this? And, crucially, where's the best current help for Applescript for someone that hasn't touched it in many years?

    Automator can do it, although some of the actions may not be obvious. Text (for example, the results of your ugly shell script) can be placed into a variable for later use, but you can also get it from a file. If your description/comment is in a plain text file, you can use the Combine Text Files action to get the text, then place it in a variable that can be used with the Set Spotlight Comments for Finder Items action.
    Example:
    1) Get Specified Finder Items (add your description file) (ignore input)
    2) Combine Text Files
    3) Set Value of Variable {Variable: whatever}
    4) Get Specified Finder Items (add the file you want to comment) (ignore input)
    5) Set Spotlight Comments for Finder Items {drag variable whatever to the text field, Append to existing comments}

  • 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

  • How to copy a files spotlight comments for an entire folder and place them in a different file with that same name

    I have the same question in a different discussion but I already marked it as solved because one of the questions was answered. Here's the linke to the other discussion if your interested https://discussions.apple.com/thread/5970421 
    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.Is there an applescript, automator, program I can download,  or program code supported in xcode that will do the following set of inscructions?
    Take the name of the picture file and spotlight comment, copy and paste it to a movie file's comments to a file 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

    Clendenen02 wrote:
    where should I run the code? in the terminal, or an applescript, or should put it in xcode and run it from there or the terminal.
    What MrHoffman said.
    But if it's easier, you can wrap it in Automator and have Automator ask for the Folders: (Test on a sample of your files before running on all 700 files)
    (do you really own 700 movies??)
    The Workflow is:
    Put this in the Run Shell Script Action (and pass input as arguments":
    PicDir=$1
    MovDir=$2
    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
    osascript <<-EOF
    tell application "Finder"
    set comment of file (POSIX file "$MovDir/$movname") to  "$comment"
    end tell
    EOF
                   fi
              fi
         fi
    done
    (BTW, I know that this is a bit of sloppy scripting (wraping an osascript in a Bash Script wrapped in Automator, but it does what you need)

  • 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

  • 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>

  • Write Filename to Spotlight-Comments

    hi!
    i'm trying to batch-write the filename to the spotlight-comments (in automator or anywhere else). can someone help me on that?
    regards tom

    paste the following into Applescript Editor, select the files whose comments you want to change and press 'run' in script 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
    repeat with thefile in mlist
    set comment of thefile to comment of thefile & return&name of thefile
    end repeat
    end tell</pre>

  • 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 ---

Maybe you are looking for