Names of PDF files attached to a note

Just wanted to share a script I created to find the name of the PDF file(s) attached to a note. This is part of my papers and ebooks library. The motivation behind was knowing the real name of the PDF, which sometimes could be an obscure number or code.

There are two key lines in the script.

  • The following line will only show the outlink element that carries an embedded document, which could be a combination of images and PDF files:

    page.file.outlinks.where(p => p.embed)
  • We eliminate the images, or keep the PDF only, with:

				.where(p => p.path.substr(p.path.length-3) == "pdf" )

This is the script.

const pages = dv.pages('"Papers" OR "Books"')
			.where(page => page.file.outlinks.embed)
			.sort(page =>, 'ac')

		.map(page => [,
				.where(p => p.embed)
				.where(p => p.path.substr(p.path.length-3) == "pdf" )

This makes it easier to find weird names of PDFs in the library and rename them - if necessary - to more meaningful names that can be identifiable in the future.

1 Like