2

Using other applescript as template, I've been trying to modify this particular one to do the following task:

Extract "Author" tag from a PDF file and write it automatically in the iTunes12 "Author" tag and for as many PDF files I select in my Books collection in iTunes (yes! I got rid of iBooks and got back Books in iTunes)

After grooming for years all my books in the iTunes library, I moved to iBooks. I didn't like iBooks so I went back to Books in iTunes. But this comeback, although worthy, it's been painful, because I lost all the iTunes tags I filled for years manually, but few at the time.

I would love to have this script done to alleviate the pain of writing the +4,000 author's book tags, which are sitting inside the properties of each of my PDFs.

My tweaked script can't get the Author tag from the PDF file and place it in iTunes. It just place the character I want to set at the end of the author in case I want to add info to the tag in the future. This is, that the only thing that appears in the iTune tag is the "-".

I'm not a expert. I'm not even a basic coder. I just try to learn, little by little about coding when I have these challenges. I've been banging my head to get this done, but this time I need help. I looked everywhere for a similar case from which I could translate the concept to no avail.

Could anyone of you please tell me what can I do to get this done. Where to look for info, what to change in the code or even say: "that's impossible"!

Thank you very much in advance!

-- PDF Meta Author to iTunes Author | script (iTunes-Acrobat)

tell application "iTunes"

set sel to the selection

if sel is {} then display dialog "Please select something" buttons {"Cancel"}

repeat with i from 1 to count of sel

    set the_track to item i of sel

    set the_alias to location of the_track as alias

    tell application "Adobe Acrobat Pro"

        open the_alias

        set authorfield to Author of document 1 as list

        set Author to item 1 of author field

        close document 1 saving no

    end tell

    set artist of the_track to (authorfield & "-") as string

    end repeat

    end tell

screenshot

0

This uses the built in unix commands to get the Author.

Try it and let me know if it needs a tweak.

tell application "iTunes"

    set sel to the selection

    if sel is {} then display dialog "Please select something" buttons {"Cancel"}

    repeat with i from 1 to count of sel

        set the_track to item i of sel

        set the_posix_path to POSIX path of (location of the_track as alias)

        set authorfield to paragraph 2 of (do shell script "mdls -name kMDItemAuthors " & quoted form of the_posix_path & "|  awk -F\\\" '{print $2'}")

        set artist of the_track to (authorfield & "-") as string
    end repeat


end tell
  • Thank you very much markhunte! It works beautifully. I'm sorry I can vote. I need more points to be able and this is my first post :( My next question: How can I get this to print names with special characters. With author like: "Odtü Kutuphanési" the printed name in iTunes is: "Odtu\U0308 Kutuphane\U0301si-" ? Only when no special characters are present in the name the printed name in iTunes is correct. Thank you! – Jostma Apr 1 '15 at 1:07
  • @Jostma You should be able accept the answer though. I can look at the character thing... – markhunte Apr 1 '15 at 6:12
  • Thank you! Please let me know if for you to do so I have to "Ask a new Question"...Thank you. – Jostma Apr 3 '15 at 14:47

You must log in to answer this question.

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