From cbb1f59715f180fcf32434af379aea180522bae2 Mon Sep 17 00:00:00 2001 From: xengineering Date: Mon, 24 Jan 2022 15:31:47 +0100 Subject: Add download script --- pcb/download.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 pcb/download.sh (limited to 'pcb/download.sh') diff --git a/pcb/download.sh b/pcb/download.sh new file mode 100755 index 0000000..dfe1be9 --- /dev/null +++ b/pcb/download.sh @@ -0,0 +1,31 @@ +#!/bin/sh + + +# constants +DOCUMENTS_FILE='documents.tsv' +CACHE='./cache' # target folder for all downloads + + +# strip first line of table file +TABLE=$(sed '1d' "${DOCUMENTS_FILE}") + +# create chache folder +mkdir -p ${CACHE} + +# download each document and save it to the cache directory +echo "${TABLE}" | while read -r line # read each line of table +do + + FILENAME=$(echo "$line" | awk -F '\t' '{print $1}') # column 1 -> filename + URL=$(echo "$line" | awk -F '\t' '{print $2}') # column 2 -> URL + + # actual download of one document + printf 'Downloading %s/%s ...' "${CACHE}" "${FILENAME}" + if wget -qO "${CACHE}/${FILENAME}" "${URL}" 2> /dev/null + then + printf " ok\n" # if wget returned with exit code 0 + else + printf " error!\n" # in any other case + fi + +done -- cgit v1.2.3-70-g09d2