Skip to content

Instantly share code, notes, and snippets.

View paulgp's full-sized avatar

Paul Goldsmith-Pinkham paulgp

View GitHub Profile
@jdingel
jdingel / NBERwp_rename.sh
Last active July 10, 2019 20:51
Shell script to automatically rename downloaded NBER WP PDFs
#!/bin/bash
#This script searches the Downloads folder for NBER working papers (PDFs starting with "w2") and renames them in "Author - Title (NBER Year)"" format.
cd ~/Downloads
papers=$(find . -name "w2[0-9]*.pdf" | sed 's/^.\//\ /' | sed 's/.pdf//' | tr -d '\n')
echo "$papers"
for wp in $papers
do
curl https://www.nber.org/papers/$wp.ris > temp.txt
grep 'AU' temp.txt | awk -F- '{print $2}' | awk -F, '{printf $1 ","}' > temp2.txt