Skip to content

Instantly share code, notes, and snippets.

@scintill
Created June 23, 2012 22:05
Show Gist options
  • Save scintill/2980245 to your computer and use it in GitHub Desktop.
Save scintill/2980245 to your computer and use it in GitHub Desktop.
rename a set of PDF's according to text found in each

The actual code (bash script) is very specific to what I was doing, but I'm putting it here so I can find it if I want to do something similar again. Or maybe it will help someone else!

#!/bin/bash
for f in *_*.pdf; do mv $f 2010`pdftk $f output - uncompress | grep -o "[0-9]\{2\}/[0-9]\{2\}" | tail -n1 | sed "s|/||g"`.pdf; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment