Created
January 20, 2015 10:35
-
-
Save samisalkosuo/5663fa9c34a1bed6879b to your computer and use it in GitHub Desktop.
Shell script to get all PragPub magazines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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