Skip to content

Instantly share code, notes, and snippets.

Last active June 22, 2022 10:02
What would you like to do?
Download PDF patent files from using download url and description
# Downloads patent files from as pdf
# Must provide 2 arguments which are.. (quotes encapsulated)
# File URL (pdf download link)
# Description or name of patent
# File will be saved as PATENT#_DESCRIPTION.pdf
# Spaces in description will be converted to dots
if [ "$#" -eq 2 ]; then
DESC="${2//\ /\.}";
# File name from the url, patent pdf file
# Complete filename to save pdf document to
# Check if patent file already exist based on patent number, download or skip
if [ ! -e *"${FNAME%*.pdf}"* ]; then
# Get pdf document and save to proper name and list downloaded file
curl -#Lko "${NAME}" "${URL}" && ls -lah "${NAME}" || echo "ERROR: Could not download file from provided URL.";
# Skip because file exist...
>&2 echo "File with patent number ${FNAME%*.pdf} already exist, skipping";
exit 1;
>&2 echo -e "$(basename $0):\n\tMust provide 2 arguments as in URL and DESCRIPTION, quotes encapsulated";
>&2 echo -e "\t\tdlpatent http://blahblah/patent.number.pdf 'Description Of Patent'";
>&2 echo -e "\t\t--> patent.number_Description.Of.Patent.pdf";
exit 1;
# Ensure definite exit code
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment