Remove Meta Title from PDF files

Hi there!

I am new to this community and new to DEVONthink. After reading a blog article about the 20th birthday of DEVONthink, I took advantage of the discount and placed an order just 24 hours later… I am just impressed with this product and happy that I’ve found an Evernote alternative - FINALLY! :slight_smile:

The last remaining „good product“ of Evernote is Scannable, which I use almost daily. It is not perfect and did not receive any updates for months, but it does a great scanning job. I just throw everything to Evernote and now DEVONthink and found out that the app sets a meta title to „Scannable-Dokument“ in every PDF file.

I just want to remove that meta title using the automatic rules. Is that possible? I set up a rule finding all PDF files with the given meta title, but I am not able to add an action to remove that meta title. I want to point out that we are not talking about the file name or name, I am referring to the meta tile displayed on „Dokument > Eigenschaften“.

I think there are ways to do this using JavaScript oder AppleScript… I am right? :slight_smile:

I would highly appreciate if someone could help me out… thanks a lot!


I’m assuming you mean the metadata displayed in the Properties inspector (called using ⌃P or Tools > Inspectors > Properties)

AFAIK you cannot do what you are asking; for AppleScript in DT meta data is a read-only property. The document title in metadata is kMDItemTitle - so whilst you can read or otherwise work with this type of metadata assigned to PDFs, you cannot alter it using AS.

Just for anybody passing: the following quick & dirty script, run from ScriptEditor, will return the metadata in question of the first selected record:

tell application id "DNtp"
	set theRecords to selected records
	set theRecord to first item in theRecords
	return meta data of theRecord
end tell

I think it just might be possible. The simple way would be something like
do shellCommand "xattr -d <file>" (with <file> being the POSIX path of the file you want to modify, without the pointy brackets, of course).

There’s a more complicated way too, using ObjC and the removexattr system call. But that’s a real PITA.

1 Like

Hi @chrillek,

thanks for pointing me in the right direction! :slight_smile:

do shellCommand "xattr -d <file>" does not work - I had to modify the command to do shell script "xattr -d <file>", but this does also not work. After I reviewed the existing meta information using xattr <file>, I found out that there is no title set for a PDF file.

But I found another solution. The title of the PDF can be read and set using the exiftool (which can be installed easily using Homebrew). Please check out my complete smart rule:

on performSmartRule(theRecords)
	tell application id "DNtp"
		repeat with theRecord in theRecords
			if type of theRecord is PDF document then
				set filepath to the path of theRecord
				do shell script "/opt/homebrew/bin/exiftool -Title=\"\" \"" & filepath & "\""
			end if
		end repeat
	end tell
end performSmartRule

This works as expected. I let it run after import and only PDF files which have „Scannable-Dokument“ set as PDF title will be modified.

Thanks a lot guys! :slight_smile:

Bye the way:

There’s a more complicated way too, using ObjC and the removexattr system call. But that’s a real PITA.

I should have mentioned that I am an iOS developer… :wink: I am not scared of Obj-C (but prefer Swift all the way)… :grinning:

You can also use do shell script "/opt/homebrew/bin/exiftool -Title='' " & quoted form of filepath

1 Like

I’m - um - glad I could “help” :see_no_evil:

It’s not Obj-C that’s scary here but the bridging between AppleScript or JavaScript and these low-level routines: Handling extended attributes | JavaScript for Automation (JXA)

If you feel adventurous, you could probably use PDFDocumentTitleAttribute of the PDFDocument class in PDFKit. It should be possible to script that via JXA (or AppleScript), too.

Welcome @WhteRbt

Glad you’re enjoying DEVONthink and getting your feet under you with some automation as well. :slight_smile: