From 99d2c46085223938fac2b3bfefb8a3677406c822 Mon Sep 17 00:00:00 2001 From: Oussama Elgoumri Date: Sat, 28 Oct 2017 18:49:44 +0100 Subject: [PATCH] download all pdf files --- .gitignore | 1 + download-all-pdf.sh | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 .gitignore create mode 100755 download-all-pdf.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..da0de7e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +pdf diff --git a/download-all-pdf.sh b/download-all-pdf.sh new file mode 100755 index 0000000..6e6591e --- /dev/null +++ b/download-all-pdf.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# --------------------------------- Create the pdf directory if not exists -- +if [ ! -d pdf ]; then + mkdir pdf +fi + +# ---------------------------------------- Add pdf directory to .gitignore -- +if [ ! -f .gitignore ]; then + echo pdf > .gitignore +else + grep -q -F 'pdf' .gitignore || echo 'pdf' >> .gitignore +fi + +# ---------------------------------------- Download pdf file if not exists -- +for f in `sed -rn 's/.*(http.+\.pdf).*/\1/pg' README.md` +do + if [ ! -f "pdf/${f##*/}" ]; then + wget --tries=3 \ + --timeout=5 \ + --waitretry=1 \ + --retry-connrefused \ + "$f" -P pdf + fi +done