The DTPO dictionary lists the following key-value pairs (on the left side, below). The element on the right side is the apparent mapping to the elements displayed in the Tools > Show Properties HUD.
Is this the correct mapping?
Where there is no rightside element shown, is there a mapping, and if so where in the DTPO interface do we see that element (apart from, I assume, the Info Panel)?
The following meta data elements are available as possible column headers, but the data is apparently not available in the DTPO dictionary. Would DTech include these elements in the dictionary as r/o?
Thank you. The longer list is perfect. Is there an un-truncated dictionary, or maybe the possibility of posting the full dictionary as pdf to the Support > Documentation page on your site?
The only possibility until Apple will fix this (and other bugs of the script editor) is to have a look at DEVONthink Pro.scriptTerminology inside the application package.
One thing I’d add is that the problem surfaces in Script Debugger as well, and so I would believe that the problem lies deeper than at the Apple editor level.
I am trying to batch change the meta-data of the current selection of documents in DEVONthink Office Pro.
I have gotten as far as this, but it won’t work except getting the current selection right:
tell application id "com.devon-technologies.thinkpro2"
try
set theSelection to the selection
if theSelection is {} then error "Please select some contents."
repeat with theRecord in theSelection
set kMDItemAuthors of meta data of theRecord to "jack"
end repeat
end try
end tell
The key-value pairs of the “meta data” record are “get” access only. Telling DEVONthink to “set” metadata is not available.
You could look into installing Sid Steward’s pdftk command line toolkit and use a shell command in your script to modify the metadata - be careful not to overwrite existing metadata values while setting a new value. Google pdftk for more information.
It’s a shame, it would be so tremendously neat in DEVONthink.
I read about pdfkit, but it seems clumsy, perhaps I can
manage to integrate it into a script for DEVONthink.
OK, the AppleScript is not finished but this is the draft (for all interested, suggestions very welcome):
tell application id "com.devon-technologies.thinkpro2"
try
set theSelection to the selection
if theSelection is {} then error "Please select some contents."
display dialog "Are you sure you want to proceed removing and then adding new metadata? (All files will be stripped of their original data)" buttons {"Yes", "No Way!!"} default button 2
if the button returned of the result is "Yes" then
repeat with theRecord in theSelection
do shell script "pdftk " & POSIX path of theRecord & " dump_data > /tmp/" & file name of theRecord & ".pdftkbackup"
---------------------- Replacing Metadata in Files ------------------------
do shell script "use awk or sed to search and replace according to line after keyword (as it is pdftk's format"
do shell script "pdftk " & POSIX path of theRecord & " update_info /tmp/" & file name of theRecord & ".pdftkbackup output" & POSIX path of file name of theRecord & "-CHANGED.pdf"
---------------------- Checking Integrity of Files ------------------------
set OriginalFileSizeInBytes to do shell script "ls -l " & POSIX path of theRecord & " | awk '{ print $5 }'"
set NewFileSizeInBytes to do shell script "ls -l " & POSIX path of theRecord & "-CHANGED.pdf" & " | awk '{ print $5 }'"
if OriginalFileSizeInBytes is "somewhat +- 3 to 4 bytes of NewFileSizeInBytes [TO_DO_CHANGE]" then
display dialog "Are you sure you want to delete the old files in favor of the new?" buttons {yes, no}
---------------------- Deleting Files ------------------------
do shell script "rm -f " & POSIX path of theRecord
else
display dialog "File Operation Failed, No Files touched, please try again." buttons {"OK"}
end if
end repeat
else
stop
end if
end try
end tell