BASEURL = 'http://192.168.1.4/pratchett/'
FILES = [l.strip() for l in open('files').readlines()]
TO = '/storage card/pratchett/'

import os
import urllib
import sys

for file in FILES:
    target = os.path.join(TO, file)
    if file.endswith('/'):
        print 'creating directory %' % (target,)
        if not os.path.exists(file):
            os.mkdir(file)
        continue
    url = BASEURL + urllib.quote(file)
    print 'downloading %s to %s' % (file, url)
    u = urllib.urlopen(url)
    fp = open(target, 'wb')
    while 1:
        c = u.read(1024)
        sys.stdout.write('.')
        if not c:
            break
        fp.write(c)
    sys.stdout.write('\n')

