I frequently receive PDF files where the first page is either empty or is just a cover page for which I have no use. Can you suggest a quick and efficient way (Applescript, Service, or ???) for me to delete just that first page and save the file?

If this can be automated via Preview or Adobe Acrobat Professional, that would be most ideal.

Any ideas?

  • 1
    This is cool. Just implemented it using Automator. Finally a long workflow :-) – Daniel Beck Feb 2 '12 at 10:48
  • Preview is unfortunately not AppleScriptable in recent versions of OS X, since Automator is soooo much more powerful. *cough* – Daniel Beck Feb 2 '12 at 11:01
  • Note that it's really easy to delete single pages in a PDF using Preview. Just select them in the sidebar and press Delete (Backspace). So if it's not too many files, that is probably the easiest solution. – Daniel Beck Feb 2 '12 at 12:07

You can do this using an Automator workflow. It's a bit more complex than most, so be careful when implementing it.

This post contains two versions: One is shorter and stores the output as Processed PDF File.pdf on the desktop, the other longer and stores the file as (Edited)InputFileName.pdf in the same directory. The steps required for the longer version only are marked (optional).

Open Automator and select to create a new Service that receives PDF files as input in Any application.

  1. (optional) Add a Set Value of Variable action and name the variable FilePath.
  2. (optional) Add a Run AppleScript action and use the following script code to get the folder name the file is located in:

    on run {input, parameters}
        tell application "Finder" to return (container of first item of input) as alias
    end run
  3. (optional) Add a Set Value of Variable action and name the variable Folder.

  4. (optional) Add a Get Value of Variable action and return the variable FilePath. Ignore this action's input in its Options.
  5. (optional) Add a Run Shell Script action and pass input as arguments. Use the following script to extract the basename of the file:

    echo "$( basename "$1" )"
  6. (optional) Add a Set Value of Variable action and name the variable FileName.

  7. (optional) Add a Get Value of Variable action and name the variable FilePath. Ignore this action's input in its Options.

  8. Add a PDF to Images action, saving output to Desktop or any folder that can hold temporary files. Name them however you want.

  9. Add a Set Value of Variable action, so we know later which temporary files to delete. Name the variable TempFiles.
  10. Add a Run AppleScript action, and use the following script code to filter the list of temporary files (this is where we remove the first page):

    on run {input, parameters}
        return rest of input
    end run
  11. Add a Combine PDF pages action to put the pieces together again, by appending pages.

  12. Use the Move Finder Items action to move the resulting file (the recombined PDF) to the Desktop, or any folder where you want them. If you decided to compute the input file's parent folder, this is where you drag & drop a reference to the Folder variable.
  13. The Rename Finder Items action can give these files a better file name than e.g. zOpY3O.pdf, which is the automatically assigned file name for the combined PDF file. Use e.g. Name Single Item and give it a basename of Processed PDF File. If you opted to use the longer variant, drag FileName from the variables list to the text field, and add (Edited) just before it. Now we're basically done, just need to clean up.
  14. Add the Get Value of Variable action and get the value of TempFiles. Ignore this action's input in its Options.
  15. Add a Move Finder Items to Trash action to remove the temporary single page files.

Here's a screenshot of the finished longer version of the workflow:

enter image description here

  • There's a bug in the shell script in the screenshot. Use the script version in the text. – Daniel Beck Feb 2 '12 at 11:56
  • 2
    Drawback of this solution: It loses all PDF metadata. – Daniel Beck Feb 2 '12 at 12:04

Using the aforementioned command-line PDF tools, I was able to compile a workflow that does the following:

  1. Take an input PDF (or PDFs) and generate a new file minus the first page
  2. Move the original PDF to the trash
  3. Rename the new file to match the original file

First I installed the PDF tools as instructed. The key tool in this case is pdfsplit.

In Automator, I created a new service to receive selected PDF files in the Finder.

I added the "Run Shell Script" action, with the shell as "/bin/bash" and "pass input" set to "as arguments." I then wrote the following simple script:

for f in "$@"
        /usr/local/bin/pdfsplit "$f" 2- > "$f".tmp

I added a "Move Finder Items to Trash" action for the original file and a "Replace Text" action to remove the .tmp extension from the new file.

To run the process with a folder input, the script would be something like:

cd "$@"
for f in *pdf
        /usr/local/bin/pdfsplit "$f" 2- > "$f".tmp

I suppose I could have done everything in the shell script, including the remove and rename. But the rm command can be dangerous, and I prefer moving the original file to the trash instead.

The script can be modified to do more than simply remove x number of pages. I've developed a similar program to batch crop and combine PDFs, for example. Check out the manual on pdfsplit and its accompanying tools for more info.


Someone at another forum developed some command-line PDF tools, incuding one that deletes pages. Looked ot be relatively easy. The only possible hiccup might be how it works with your workflow. From your description, it looks you'd something that works while the PDF is open and these tools seem to work (better) with a closed file.


Just to add to the answer provided by Joseph Yannielli, for those who decide to run the shell script it may be easier to include commands to delete and rename the file in the script instead of adding separate actions via Automator:

for f in "$@"
    /usr/local/bin/pdfsplit "$f" 2- > "$f".tmp
    rm "$f"
    mv "$f".tmp "$f"

On the matter of installing command line PDF tools, it can be conveniently done with use of the Homebrew:

brew install pdf-tools

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.