Remove PDF page with applescript?

HI all, I have a script that appends PDFs into one file using filemaker. To make this work you have to have a first ‘title’ page, that operates as the first path that other pdfs are ‘attached’ to. I’d prefer to remove this first page on the pdf.

Is there a way for an applescript to locate a recently exported PDF from filemaker and remove the first page?


I can’t help about what is directly related to FileMaker.
About the page removal you may look at this Shane STANLEY’s script

-- Modified 2016-07-18 by Takaaki Naganoya
--Original By Shane Stanley
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "Quartz"
use framework "QuartzCore"

set inFile to (choose file of type {"pdf"} with prompt "Choose your PDF files:")
set targPage to 2
set maxPage to pdfPageCount(inFile) of me
if 0 < targPage and targPage ≤ maxPage then
	display dialog "Page Number Range Error"
end if

removeSpecificPageInPDF(inFile, targPage) of me

on removeSpecificPageInPDF(inFile, targPageNum)
	-- make URL of the first PDF
	set inNSURL to current application's |NSURL|'s fileURLWithPath:(POSIX path of inFile)
	set theDoc to current application's PDFDocument's alloc()'s initWithURL:inNSURL
	set oldDocCount to ((theDoc's pageCount()) - 1)
	--Make Blank PDF (deleted PDF)
	set newPDFdoc to current application's PDFDocument's alloc()'s init()
	set newDocCount to 0
	repeat with i from 0 to oldDocCount
		if i is equal to (targPageNum - 1) then
			--log {"skip page at:", i}
			--log {i}
			set thePDFPage to (theDoc's pageAtIndex:i) -- zero-based indexes
			(newPDFdoc's insertPage:thePDFPage atIndex:newDocCount)
			set newDocCount to newDocCount + 1
		end if
	end repeat
	set aRes to deleteFile(inFile) of me
	if aRes = true then
		set aRes to (newPDFdoc's writeToURL:inNSURL)
	end if
	return aRes
end removeSpecificPageInPDF

on pdfPageCount(aFile)
	set aFile to POSIX path of aFile
	set theURL to current application's |NSURL|'s fileURLWithPath:aFile
	set aPDFdoc to current application's PDFDocument's alloc()'s initWithURL:theURL
	set aRes to aPDFdoc's pageCount()
	return aRes as integer
end pdfPageCount

on deleteFile(aFile)
	set aPath to POSIX path of aFile
	set filePath to current application's NSString's stringWithString:aPath
	set fileManager to current application's NSFileManager's defaultManager()
	set aRes to fileManager's removeItemAtPath:filePath |error|:(reference)
	-->	{‹‹‹‹‹true, ‹‹‹‹‹missing value‹‹‹}
	-->	{‹‹‹‹‹false, ‹‹‹‹‹(NSError) Error}
	copy aRes to {aFlag, aReason}
	return aFlag
end deleteFile

Yvan KOENIG running El Capitan 10.11.6 in French (VALLAURIS, France) dimanche 7 aout 2016 10:13:40