Skip to content

Instantly share code, notes, and snippets.

@samisalkosuo
Created January 20, 2015 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samisalkosuo/5663fa9c34a1bed6879b to your computer and use it in GitHub Desktop.
Save samisalkosuo/5663fa9c34a1bed6879b to your computer and use it in GitHub Desktop.
Shell script to get all PragPub magazines.
#!/bin/sh
echo "Retrieving all 49 issues of PragPub as epub..."
echo "Downloading files to $DIR..."
DIR=pragpub
mkdir $DIR
function getPragPub {
EXT=$1
cd $DIR
for i in {1..49}
do
echo "Retrieving $i..."
wget http://pragprog.com/magazines/download/$i.$EXT
done
cd ..
}
function rename {
EXT=$1
cd $DIR
for i in {1..49}
do
F=$i.$EXT
if [ $i -le 9 ]; then
NF=PragPub_0$i.$EXT
else
NF=PragPub_$i.$EXT
fi
echo Renaming $F to $NF...
mv $F $NF
done
cd ..
}
#EXT can be also PDF or mobi
EXT=epub
getPragPub $EXT
rename $EXT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment