Page 1 of 1

Write to PDF metadata?

Posted: Fri Apr 25, 2025 2:08 pm
by frankel
Hi,

MP3 players used back in the days of ripping CDs could write track info to the metadata of the file, such that this info could travel with the file. PDFs also carry with them metadata. Can the file info from a bookends database somehow be written to the metadata of PDF of a library? Thanks in advance.

Christian

Re: Write to PDF metadata?

Posted: Fri Apr 25, 2025 3:25 pm
by Jon
No, Bookends can't do that. Not even Preview does that. There are dedicated apps that can, however, like Adobe Acrobat Reader (Edit Document Properties). You can google for other apps or utilities that let you modify a PDF's metadata.

Jon
Sonny Software

Re: Write to PDF metadata?

Posted: Tue Apr 29, 2025 2:38 pm
by Dellu
There are a couple of scripts that do this within BE.
You can search in this forum< or just google around.
Personally, I use the following script, to write metadata. It relies on exiftools.

Code: Select all

tell application "Bookends"
	set theIDs to «event ToySRUID» "Selection"
	repeat with theID in paragraphs of theIDs
		tell front library window
			try
				set myRefs to (publication items whose id is theID)
				set myItem to first item of myRefs
				set thePath to path of attachment items of myItem
				if thePath is not {} then
					set {theKey, thePath, theAuthor, theEditor, theTitle, theWords, theYear} to {citekey, path of attachment items, authors, editors, title, keywords, publication date string} of myItem
					if theAuthor = "" then set theAuthor to theEditor
					set theMonth to (do shell script "date '+:%m:%d %H:%M:%S'")
					set theDate to (theYear & theMonth)
					set otid to AppleScript's text item delimiters
					set AppleScript's text item delimiters to linefeed
					set thePath to text items of thePath
					repeat with i in thePath
						set thisPath to i as string
						tell application "Finder" to set theName to name of (POSIX file thisPath as alias)
						set AppleScript's text item delimiters to otid
						
						try
							do shell script "/usr/local/bin/exiftool -title=" & quoted form of theTitle & " -author=" & quoted form of theAuthor & "  -keywords=" & quoted form of theWords & " -CreateDate=" & quoted form of theDate & " -overwrite_original " & quoted form of thisPath
						end try
					end repeat
					
				end if
				
			on error errorMessage
				
			end try
			
		end tell
	end repeat
end tell
If that is not an option, you can try Jabref. Jabref does write metadata into the pdf files (xml)