Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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.

MacBook Pro, OS X Mavericks (10.9.2)

Posted on Mar 6, 2014 1:51 PM

Reply
Question marked as Best reply

Posted on Mar 6, 2014 2:00 PM

Use an AppleScript such as:


set the_string to ""

tell application "Finder"

repeat with this_file in (get files of folder "untitled")

set the_string to the_string & name of this_file & tab & comment of this_file & return

end repeat

end tell

the_string


Copy the result and paste it into the desired application.


(102033)

12 replies
Question marked as Best reply

Mar 6, 2014 2:00 PM in response to Clendenen02

Use an AppleScript such as:


set the_string to ""

tell application "Finder"

repeat with this_file in (get files of folder "untitled")

set the_string to the_string & name of this_file & tab & comment of this_file & return

end repeat

end tell

the_string


Copy the result and paste it into the desired application.


(102033)

Mar 7, 2014 8:12 AM in response to Clendenen02

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

Mar 12, 2014 4:24 PM in response to Clendenen02

Run the following AppleScript exactly as written, go to the desired application, and paste the clipboard contents:


set the_string to ""

tell application "Finder"

repeat with this_file in (get files of (choose folder))

set the_string to the_string & name of this_file & tab & comment of this_file & return

end repeat

end tell

set the clipboard to the_string


(102516)

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

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.