Skip to content

Instantly share code, notes, and snippets.

@willangley
Created July 4, 2020 20:36
Show Gist options
  • Save willangley/d69337a09089765ef7d0dba6a8603dee to your computer and use it in GitHub Desktop.
Save willangley/d69337a09089765ef7d0dba6a8603dee to your computer and use it in GitHub Desktop.
#!/bin/zsh
# Copyright 2020 Google LLC.
# SPDX-License-Identifier: Apache-2.0
# For use as a step in an Automator action.
# Expects input to be passed as arguments.
export PATH=/usr/local/bin:$PATH
for pdf in "$@"; do
out_pdf="$(mktemp ocrmypdf.XXXXXX)"
ocrmypdf --rotate-pages --deskew "$pdf" "$out_pdf"
osascript -e "tell application \"Finder\" to delete POSIX file \"${pdf}\""
mv "$out_pdf" "$pdf"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment