Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Planten

macrumors newbie
Original poster
Aug 19, 2009
2
0
Hello everyone.

I am new here and in no way proficient, when it comes to coding and the like.
Which is why I have made an account here to ask for help.

I was searching for an easy way to download the comics found at http://www.elfquest.com/gallery/OnlineComics3.html which are posted as jpegs.

In my search I stumbled upon a script made by Robert 'Bobby' Zenz at http://www.bonsaimind.org/ which would do the job of downloading all the files.

My question is if this script would work with a mac and if so, how do I use it? I realize this must be quite the noob question, but as earlier stated, I have no knowledge in this area. So I'd be most greatful if someone could help me :)

Also, if anyone should know an easier way to get all the files, I'd appreciate the input!

Here is the script:
Code:
#!/bin/bash
# This is a simple script to download all of the
# ElfQuest comics directly into a directory hirarchy
# created on the fly...
#
# Written by Robert 'Bobby' Zenz
# The GPL applies...however may care...


# Some sample Links:
#	http://www.elfquest.com/gallery/OnlineComics/OQ/OQ01/oq01-0.jpg
#	http://www.elfquest.com/gallery/OnlineComics/SABM/SABM01/sabm01-0.jpg


# Array of all known Comics
comics[0]=OQ
comics[1]=SABM
comics[2]=KOBW
comics[3]=ESS
comics[4]=HY
comics[5]=SH
comics[6]=NB
comics[7]=TC
comics[8]=KA
comics[9]=TS
comics[10]=JK
comics[11]=RB
comics[12]=MET
comics[13]=EQ2
comics[14]=WD

# This are some variables which we'll need along the way
COUNTER_ISSUE=1
COUNTER_PAGE=0
END_ISSUE=0
STILL_PAGES=0

# loop through all the comics
for comic in "${comics[@]}"; do

	# reset the issue counter
	let COUNTER_ISSUE=1

	# now get all the issues
	while [ $END_ISSUE -eq 0 ]; do
	
		# if the directory does not exist, create it	
		if [ ! -d $comic`printf "%02d" "$COUNTER_ISSUE"` ]; then
			mkdir $comic`printf "%02d" "$COUNTER_ISSUE"`
		fi
		
		# reset the counter
		let COUNTER_PAGE=0
		let STILL_PAGES=0
		
		# get the pages
		while [ $STILL_PAGES -eq 0 ]; do
			
			# check if the file aready exists...
			if [ ! -e $comic`printf "%02d" "$COUNTER_ISSUE"`/`echo $comic | tr '[A-Z]' '[a-z]'``printf "%02d" "$COUNTER_ISSUE"`-$COUNTER_PAGE.jpg ]; then
				# Actual Loading
				wget -c --tries=1 --directory-prefix=$comic`printf "%02d" "$COUNTER_ISSUE"` http://www.elfquest.com/gallery/OnlineComics/$comic/$comic`printf "%02d" "$COUNTER_ISSUE"`/`echo $comic | tr '[A-Z]' '[a-z]'``printf "%02d" "$COUNTER_ISSUE"`-$COUNTER_PAGE.jpg 
			
				# save the exit code
				let STILL_PAGES=$?
			else
				# set the exit code
				let STILL_PAGES=0				
			fi
			
			# increment the page counter if we found something
			if [ $STILL_PAGES -eq 0 ]; then
				let COUNTER_PAGE=COUNTER_PAGE+1
			fi
		done
	
		# if there were no pages
		if [ $COUNTER_PAGE -eq 0 ]; then
			# we can guess that there are no more issues...
			let END_ISSUE=1
			# ...and remove the directory we just created
			rm -rf $comic`printf "0%u" "$COUNTER_ISSUE"`
		else
			# increment the issue counter...
			let COUNTER_ISSUE=COUNTER_ISSUE+1
		fi
	done
	
	# reset the trigger
	let END_ISSUE=0
done
 
It's just a standard bash script, so it should (edit: does) work. Unfortunately it uses wget which isn't on Macs by default, so that bit won't work.

If you have the developer tools installed, you can get the GNU wget from http://ftp.gnu.org/gnu/wget/ - and build and install it yourself.

Otherwise, I think there are binaries out there you can install, but I'd prefer building it myself.

Edit: Oops, I didn't say how to use it. Copy this to a file and call it e.g. comic.sh - put the file in a folder called e.g. comics.

Open a Terminal from Applications/Utilities. Type:
Code:
cd comics

Make the script executable:
Code:
chmod 777 comics.sh

Assuming you have a version of wget, type:
Code:
./comics.sh

and wait for it to finish.
 
It's just a standard bash script, so it should (edit: does) work. Unfortunately it uses wget which isn't on Macs by default, so that bit won't work.

If you have the developer tools installed, you can get the GNU wget from http://ftp.gnu.org/gnu/wget/ - and build and install it yourself.

Otherwise, I think there are binaries out there you can install, but I'd prefer building it myself.

Install finkcommander (google for it) and use that to install wget. Much easier than building the binaries yourself, especially if you don't recognise Bash as something that could run on a Mac.
 
Thanks!

Thank you so much for your quick and elaborate responses :)
I will try this out as soon as I get the opportunity.
Hopefully I won't ruin anything (;
 
MacOS has a curl as a substitute for wget. I think the script could be modified to use it instead of installing wget for that sole purpose.
 
I deliberately didn't mention curl since it's not a drop in replacement for wget. The options are different, and it doesn't write to file. Modifying the wget command to curl wasn't something the OP could do, and I couldn't be bothered trying it myself.

As for fink ... it's a decent gnu package manager for OS X, but managing it is much more involved than downloading http://ftp.gnu.org/gnu/wget/wget-1.11.4.tar.gz, unzipping the file and typing "./configure; make -j2; sudo make install" in the command line. Building your own version of wget (or some other gnu executables) means you get only what you need instead of a whole new package management system.
 
Hey, I know this is an old thread but couldnt really find a way to message the author personally.

But I am currently also trying to download all the Elf Quest comics and wonder if the OP ever found a reasonable way? What I've done so far was installing a program called "DeepVacuum" and downloaded every image on the site and included the subsites, so now I got 1 folder with ALL the comics and banners etc. which needs to be organised manually etc.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.