+#! /bin/bash
+
+# get a list of urls and corresponding output file names, then parse them to wget
+
+args=("$@")
+list=${args[0]}
+
+if [[ $list == "" ]]
+ then
+ printf "\n\x1b[31mWrong number of arguments\x1b[0m\n\n"
+ printf "Usage: nameget LIST [DESTINATION] [ARGS]\n where LIST is a text file of format [url] [name] (one pair per line)\n [DESTINATION] is a path appended to the start of each [name] in LIST\n [ARGS] is passed directly to wget"
+ exit 1
+fi
+
+if [[ -d ${args[1]} ]]; then # check if args[2] is [DESTINATION] or [ARGS]
+ outdir=${args[1]}
+ if [[ ! $outdir =~ /$ ]]; then # check if [DESTINATION] has a trailing /
+ outdir=$outdir/
+ fi
+ shift 2
+else
+ shift 1
+fi
+
+otherargs=$@ # set aside remaining arguments for passing to wget
+
+while read -r url filename tail; do
+ wget --cut-dirs=100 -r -np -nc --accept -e robots=off -O "$outdir$filename" "$url" $otherargs
+done < $list