Advertisement
markruff

NEJM PDF rename

Dec 31st, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.52 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. #
  3. # nejm_pdf_rename
  4. #
  5. # Author: Mark Ruff
  6. #
  7. # Strips the title out of a pdf file and renames the pdf accordingly.
  8. # Written for NEJM clinical practice guidelines. Will need modification
  9. # to work with other files (hopefully not much)
  10.  
  11. # Standard line of text which allows us to find the title
  12. MARKER="clinical practice"
  13.  
  14. # Number of lines below the MARKER that the titlte appears
  15. LINES=2
  16.  
  17. for FILE in $@
  18. do
  19.     mv "$FILE" "$(less "$FILE" | grep -A $LINES -m 1 "$MARKER" | sed -n -e "$((LINES+1)) p").pdf"
  20. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement