Skip navigation

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

788 Views 2 Replies Latest reply: Nov 19, 2012 4:57 PM by Evan Izer RSS
Evan Izer Calculating status...
Currently Being Moderated
Nov 19, 2012 11:59 AM

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:

 

screenshot.jpg

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

 


Mac Pro, Mac OS X (10.6.8)
  • Jacques Rioux Level 4 Level 4 (1,925 points)

    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
    

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.