Created
March 16, 2019 12:18
-
-
Save k-nut/c8c8e321a04daf0b64fc5781d6a387d4 to your computer and use it in GitHub Desktop.
Tax Time PDF collector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set tmp_dir (mktemp -d) # create a temporary directory | |
for file in (ls Account*.pdf) # match all files to be included | |
pdfseparate $file $tmp_dir/$file--%03d.pdf # split pdfs page wise into tmp dir | |
end | |
for file in (ls $tmp_dir/*.pdf) # iterate through all split pages | |
if pdftotext $file - | grep 'EUROPEAN' # check if they contain our search string | |
set matches $matches $file # append to our match list | |
end | |
end | |
pdfunite $matches all.pdf # take all the matched pages and merge them into all.pdf | |
test -n "$tmp_dir"; and rm -r $tmp_dir # make sure tmp dir exists and remove it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment