2

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.

  • Wouldnt it be easier to just understand how that spotlight comment is stored, and potentially do it with a little program directly from the shell? – ConstantineK Mar 29 '16 at 19:27
  • Gosh! Coding and me are water and fire. I was suggested this channel to find an answer in that direction. I'd be already happy to know it could be done. That way I can look further for that solution. – Automator Mar 29 '16 at 19:30
  • No worries, I did a little more digging as I was interested. amsys.co.uk/2013/02/… Describes a method to create a drag and drop target that automatically tags anything dragged on top of with the tag you choose, you could make several "tag drop points" and then tag as many as you want... upon furtrher review you want the filename itself to be part of the tag, so this would be more difficult. I will think more. – ConstantineK Mar 29 '16 at 19:31
  • Feel happy an amateur like me inspired a pro like you :D Still not what I'm looking for I think. Request specification. One folder contains 1.000 files. They all have different file names. Most have movie format extensions. I want the script to target (one by one) those thousand names, copy (one by one) the original name and paste it (one by one) in the Spotlight Comment boxes of the OS X 10.8.5. files. When done, the script should rename the original file name by putting the prefix DONE_ in front of that original name. – – Automator Mar 29 '16 at 19:36
  • 1
    Welcome to Ask Different. If you could edit your post to show two example names. When someone automates this - you have to consider are there spaces in the file names? Unicode? Oddball punctuation? Also - please tell me you have everything backed up in case the tool renames all the files to contain the contents of the index or other "oops" :-) – bmike Apr 8 '16 at 15:50
4

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

  • HOLY SHIT GUYS! Am I allowed to kiss somebody's feet for this? I rated the awesome spirit who wrote this code 'up' but he didn't even get one single point for it. Could somebody else reward him/her in my place for this PLEASE! Even though my neck hurts like crazy, it starts looking like I even don't feel it anymore after this awesome input. Praise the lord whichever one you prefer. So at last THERE IS HOPE FOR PEACE NOW. Even though I was not allowed to thank you for this, I'm gonna do it anyways! – Automator Apr 11 '16 at 10:25
  • @Automator Yours is a good question and I'm sorry no one else up voted it. I've +1 your question and this very helpful answer. Keep asking good questions and/or answering and you'll have rep to vote "officially" and even voting when you can't give +1 helps others find this post (it rises above masses of posts that never even get an anonymous up tick in search results and featured posts). – bmike Apr 11 '16 at 18:07
  • @jackjr300 , I know 7 months later but what you did was just awesome. How can I now change the current names of these thousands of files into: – Automator Nov 15 '16 at 17:39
  • @jackjr300 , (I know 7 months later) but what you kickstarted was just awesome. They should give you a reward for this. How can I now change the current renamed: "Done_" names of these thousands of files into: 1_2_3_4_5_6_7_8_9, so they would rename automatically to what you just saw and the Done being replaced by the number set. After that I would need to target each number separately, but that will be the next question. – Automator Nov 15 '16 at 17:48
0

Download with Description

For gathering future YouTube contributions, consider downloading the files using the open source tool youtube-dl. youtube-dl can automatically put the YouTube meta-data into the downloaded file, so that it is accessible by Spotlight on OS X.

As an example, the following command downloads every Global Mission of Peace YouTube video. The resulting video files are fully commented using the YouTube descriptions and meta-data:

youtube-dl --download-archive youtube-dl-archive.txt --ignore-errors --recode-video mp4 --xattrs --add-metadata --output "%(upload_date)s-%(uploader)s-%(title)s.%(ext)s" https://www.youtube.com/channel/UCkEumUlzJWfaz46dBc0H9FQ/videos

You can install youtube-dl using the Homebrew project and, after brew is installed, the following Terminal.app command:

brew install youtube-dl
  • I appreciate this is not a direct answer but I hope it helps save @Automator time in the future. – Graham Miln May 13 '16 at 10:47
  • I'm back after 7 months of researching and testing. @jackjr300 had the best Automator script to start building on as all other options proved to clutter the info window of the spotlight comment field. Too long and not practical to validate. I like the idea to generate the download link itself though. E.g. youtube.com/watch?v=1A-hqZf7xQs and most likely 16:9 being added on the fly. But what I am getting now always has to be wiped out first to be manually rewritten for every single download. Now I'm using cloudfile and I'm really pleased with my current work flow. – Automator Nov 15 '16 at 19:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .