MacOS – Wanted: Apple Script for copying file name and pasting it in Spotlight Comment box Mac OS X 10.8.5

applescriptautomatormacosspotlight

Global Peace Mission Project looking for automating pre sorting movie file routines. Due to the instant impact inflow of third party YouTube contributions triggered by a blog launched March 22 after the Brussels ISIS attacks, I need an Apple Script. Can one automate the pre sorting process of copying the original file name of the footage and pasting it in the Spotlight comment box of that file? How does that Apple Script for OS X looks like?

I would need to do THIS a thousand times otherwise (and meanwhile stacking up)and I'm not the only one getting repetitive strain injuries because of that.

If you don't know the answer, please help us find the one who does. Tx.

This is how insane we do it now…

  1. Hitting enter to select the file
  2. Cmd C (To copy the file name)
  3. Cmd I to open that info window
  4. Hitting tab button twice to enter the Spotlight Comment box
  5. Cmd v (To paste the file name in the box)
  6. Cmd w to close that info window
  7. Hitting enter to select the file again
  8. Putting the cursor in front of the file name
  9. Adding DONE_ in front of the name so I would see that one is done

The aforementioned folder contains a thousand files and even more.
So I wish the script could batch import all of them at once, one after the other.

Best Answer

This AppleScript ask you to choose some files, after that, it set the comment of each file to the file name.

set input to choose file with prompt "Select files (to put the file name into the Spotlight Comment)" with multiple selections allowed
tell application "Finder"
    repeat with i in input
        tell item i to try
            set tName to (get name)
            set comment to tName -- this set the comment to the name of the file, and delete the existing comment
            set name to "Done_" & tName
        end try
    end repeat
end tell

If you want to append the file name to the existing comments, change the sixth line in the script to set comment to (get comment) & " " & tName -- this append the name of the file to the existing comment