C-Command Software Forum

pdf to pdfd

A recent feature I really like of EF is the ability to display skim notes. I’m now using this a lot when reviewing papers.

My current workflow is:

  • if the paper is a .pdf, convert it to a .pdfd (pdf bundle) format
  • import the .pdfd into EF, remove the .pdf from EF
  • add notes using skim, they will now show in EF

I would like to easily convert a .pdf to .pdfd inside EF, without having to import the file again (as its name changed). Could it be considered as a feature request? (I guess a workaround could be an applescript…)

Here’s a script that will do this.

Great, thanks a lot. It almost works perfectly, the only caveat being the new file name. For instance, if I start with file name
Detail RIBs.pdf
the resulting file name is now
EFPDFToPDFD.GKqeado0Detail RIBs.p.pdfd

The first bug is in the computing of the base name. I experimented a bit and it seems that

set _base to characters 1 thru -_extensionLength of _name

will return the whole string if _extensionLength is “1”, so you need to add 1 to the length, and include the “.” in the extension (or don’t add it at the end). Here is the new method:

on pdfdNameForRecord(_record)
	tell application "EagleFiler"
		set _name to _record's filename
		if _name ends with ".pdf" then
			set _extensionLength to ((length of ".pdf") + 1)
			set _base to characters 1 thru -_extensionLength of _name
			set _base to _name
		end if
		return _base & ".pdfd"
	end tell
end pdfdNameForRecord

For the second small bug (remove the temp prefix), I don’t know how to do it. Is there a way to specify the file name when importing, or to change it after it’s imported?

Oh, and a small suggestion: the copyMetadata seems a very useful function. Maybe you could make it available in EF’s AppleScript dictionary (if such a thing is possible).

Sorry about that. I accidentally had the File column turned off in my test library, so I didn’t notice the name problems. Here’s a corrected script.

Yes, that’s something I’d like to do. This would allow it to copy the formatting for the notes; right now, it only copies the notes as plain text, since that’s what AppleScript works with.

You may notice that the copyMetadata function is a little different in the various scripts I’ve posted. The scripts don’t all want quite the same thing. So the AppleScript command would probably need some options for choosing what to copy (or not copy).

Works great, thanks. I have one final question: why does the record has a URL after the script? (The URL is a file://localhost one that points to the file, except it ends in .pdf.)

Guess: you don’t display the URL if it points to the current file, but as you copy it from the .pdf file, it’s different from the current file, so it’s displayed.

It really does not matter, and it actually highlights what you were saying about which metadata needs to be copied.

Sort of. I’ll make some changes in EagleFiler itself so that a blank source URL stays blank.

I’ve fixed this in EagleFiler 1.4.4.

Is it an easy mod to have the script assign the Date Added of the pdf to the pdfd? For those who sort by date added, that would retain the item’s place in the record list.

It’s not currently possible to set the Date Added via AppleScript, but I will add that as a feature request.

I’ve updated the script to do this. It requires EagleFiler 1.5.4.


As a follow-on, could the pdf-to-pdfd be set to apply the date added of the pdf to the pdfd?

Isn’t that what the script does now?

My mistake-- I was using an older version.