UPDATE If you need some more help figuring out how to use this check out my new post that explains it in a bit more detail!

I had an idea while watching WLUK’s Lambeau Cam, a webcam mounted on a radar tower near Lambeau field. I thought it would be cool to download images of a webcam at a set interval and then convert them into a movie format. The result would be a stop motion (or time lapse) video of that webcam’s output.

While I was writing this script I remembered that WLUK already broadcasts a time lapse video of the Lambeau Cam almost every night during their weather forecast but this didn’t stop me because it can be used on more than just a web cam.

Description:` iget.sh (aka. Interval Get) is passed three parameters. 1. The URL of a file; 2. A file name to tag the downloaded file with; 3. An Interval in seconds.

iget will download the URL, tag it with the date and time and your custom file name at the interval of seconds you tell it.


./iget.sh http://weather.myfoxnewisconsin.com/maps/WLUK/lambeaucam/capture.jpg lambeau.jpg 60

This would output YYYY-MM-DD_HHMMSS_lambeau.jpg every sixty seconds.

Dependencies: Bash wget

Note: Before running this script you may have to give it Execute permissions. You can do this using chmod:

chmod +x ./iget.sh

Also, I have tested this in Ubuntu v7.04 and in Cygwin, it worked fine on both.

# iget.sh
#  Author: Gregory Strike
#     URL: //www.gregorystrike.com/2007/06/06/bash-script-interval-get/
# Purpose: This script downloads a file from the Internet at a set interval.
# Syntax:
# iget url filename i
# Where filename = The custom file name
# Where i = the interval of the download in seconds
function download()
	wget $url -O $(date '+%Y-%m-%d_%H%M%S')_$filename
function pause()
	echo Downloading $url...
	echo Interval is set to $interval seconds...
	echo -n "Next download in "
	(( intervalleft=interval ))
	while (( intervalleft > 0 ))
		echo -n -e "$intervalleft seconds..."
		if ((${intervalleft:${#intervalleft}-1:1}==9))#Detects if there is a nine at the end
			echo -n -e " \\b"			#If so, write a space and then backspace
		sleep 1						#Zzzzzz...  For 1 second.
		echo -n -e \\b\\b\\b\\b\\b\\b\\b\\b\\b\\b\\b	#Erases the "seconds..."
		backspaces=${#intervalleft}			#Get the current number of digits
		while (( backspaces > 0 ))			#Loop until the last digit has been backspaced
			echo -n -e \\b
			(( backspaces-- ))
		(( intervalleft-- ))
if (( $# != $REQPARAMS ))
		echo "Error: Incorrect Syntax"
		echo "Required: " $REQPARAMS " Passed: " $#
		echo "Syntax: ./iget.sh url filename interval"
		echo "URL = The URL/location of the file."
		echo "FILENAME = Base name of the file saved locally."
		echo "INTERVAL = The seconds between downloads."
while ((1))

After you have downloaded all the pictures you should be able to use a program that can convert many pictures into a movie. I used mencoder, which was easy to setup on Ubuntu, a little more difficult on Cygwin.

Here’s an example of a time lapse I created from the LambeauCam on LambeauField.com. I used the script above and meconder to create this. Those l337 may recognize the sound track! :)

Have Fun!

Gregory Strike

Husband, father, IT dude & blogger wrapped up into one good looking package.