markruff icon

NEJM PDF rename

markruff | PRO | 01/01/16 03:27:02 AM UTC | 0 ⭐ | 387 👁️ | Never ⏰ | []
Bash |

520 B

|

None

|

0 👍

/

0 👎

#!/usr/bin/env bash
#
# nejm_pdf_rename 
#
# Author: Mark Ruff
#
# Strips the title out of a pdf file and renames the pdf accordingly.
# Written for NEJM clinical practice guidelines. Will need modification
# to work with other files (hopefully not much)
 
# Standard line of text which allows us to find the title
MARKER="clinical practice"
 
# Number of lines below the MARKER that the titlte appears
LINES=2
 
for FILE in $@
do
    mv "$FILE" "$(less "$FILE" | grep -A $LINES -m 1 "$MARKER" | sed -n -e "$((LINES+1)) p").pdf"
done

Comments