This file contains hidden or 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
#!/bin/bash | |
# This script searches for NBER working papers (PDFs starting with "w2") and renames them in "Authors - Title (NBER Year)"" format. | |
# Arguments : | |
# $1 = folder to be searched. If left empty, look into Downloads | |
if [ -z $1 ]; then folder="~/Downloads"; else folder="$1"; fi | |
function getMoveCommand { | |
while read data; do | |
curl "http://www.nber.org/papers/${data}.ris" | awk -v folder="${folder}" -v quote="'" -F" - " '{if ($1=="AU") {sub(/,.*/,"",$2); authors=authors", "$2} else if ($1=="TI"){title=$2} else if ($1=="PY") {year=$2} else if ($1=="L1") {gsub(/.*\//,"",$2); file=$2}} END {sub(/^, /,"",authors); print "mv "folder"/"file" "quote""folder"/"authors" - "title" ("year").pdf"quote}' | |
done | |
} |
This file contains hidden or 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
import ply.lex, argparse, io | |
# modified from https://gist.github.com/amerberg/a273ca1e579ab573b499 | |
#Usage | |
# python stripcomments.py input.tex > output.tex | |
# python stripcomments.py input.tex -e encoding > output.tex | |
# Modification: | |
# 1. Preserve "\n" at the end of line comment |