Skip to content

Instantly share code, notes, and snippets.

@petertoi
Created February 23, 2015 14:46
Show Gist options
  • Save petertoi/b61ac28f2cd27a2c645d to your computer and use it in GitHub Desktop.
Save petertoi/b61ac28f2cd27a2c645d to your computer and use it in GitHub Desktop.
Download sequentially named files from command line
#!/bin/bash
#
# Author: Peter Toi
# Source: https://gist.github.com/petertoi/b61ac28f2cd27a2c645d
#
# Usage 1: $ wgetseq.sh # No argument will result in prompts
# Usage 2: $ wgetseq.sh starturl endurl startnum endnum # Skip the prompts by including the arguments
if [ "$#" -eq 4 ]
then
starturl=$1
endurl=$2
startnum=$3
endnum=$4
else
echo "Start URL (i.e.: http://domain.com/image-): "
read starturl
echo "End URL (i.e.: .jpg): "
read endurl
echo "Start Num: "
read startnum
echo "End Num: "
read endnum
fi
for i in `seq $startnum $endnum`;
do
echo "Downloading: "$starturl$i$endurl
wget $starturl$i$endurl
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment