1

I have a PDF file. If I look at the Get Info window, the Title under More Info is "Title1". I am trying to set this value using terminal so I can eventually turn it into an applescript.

See Stackoverflow question Mac OS X : add a custom meta data field to any file

I used the answer from Anderson Freitas to correctly set an author by using the command"

xattr -wx "com.apple.metadata:kMDItemAuthors" "`xxd -ps author.plist`" "Put File Name Here.pdf"

However, if I replace kMDItemAuthors with mMDItemTitle, the command runs without error, but no changes are seen in the title either by looking at Get Info or by using mdls on the command line.

The contents of my title.plist file is:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<string>Title2</string>
</plist>

The actual command I run to set the title is:

xattr -wx "com.apple.metadata:kMDItemTitle" "`xxd -ps title.plist`" "Put File Name Here.pdf"

Any thoughts where I might be doing something wrong?

4
  • Just because the authors metadata is (or can be) stored in an extended attribute, that doesn't mean that all metadata is. The title presumably comes from the PDF content itself, extracted by the Spotlight importer for PDF documents. If so, then there's no extended attribute that you could set or modify to change it. You could check if the original file (without your modifications) has such an extended attribute using ls -l@. Even if there is an extended attribute, its data format would be an implementation detail. You can't assume it's a plist. Oct 5, 2014 at 5:15
  • A little more info based on your answer:
    – ccampj
    Oct 5, 2014 at 5:21
  • (Sorry, first comments can't be edited) A little more info based on your answer: 1. You are correct, no extended attributes show up from ls -l@ on the original file. However, mdls on the original file show both the kMDItemAuthors and kMDItemTitle attributes. 2. I can set both of these attributes through Automator "Set PDF Metadata". After doing so, both of the attributes show up using ls -l@ 3. So while I agree, I cannot assume the title is a plist, does anyone know what it might be and how it could be set?
    – ccampj
    Oct 5, 2014 at 5:27
  • This question appears to be off-topic because it is not about programming. See What topics can I ask about here in the Help Center. Perhaps Super User or Apple Stack Exchange would be a better place to ask.
    – jww
    Oct 5, 2014 at 5:57

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.