Skip to content

Instantly share code, notes, and snippets.

@dddExperiments
Created November 13, 2016 02:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dddExperiments/cd5eae7f420411a5f67257df949f37f1 to your computer and use it in GitHub Desktop.
Save dddExperiments/cd5eae7f420411a5f67257df949f37f1 to your computer and use it in GitHub Desktop.
import os
import subprocess
import urllib
import sys
# you need to pass the _list.txt file as 1st argument.
# python download_list.py ps2_list.txt
f = open(sys.argv[1], 'r+')
for line in f:
tmp = line.split(" ")
guid = tmp[0]
print "Processing: %s" % guid
url = tmp[2].rstrip('\r\n') # remove end of line
filename, file_extension = os.path.splitext(url)
target_file = guid + file_extension
tmp_file = guid + ".tmp"
if os.path.isfile(tmp_file):
# delete temporary file
os.remove(tmp_file)
if not os.path.isfile(target_file):
# download url to temporary file
urllib.urlretrieve (url, tmp_file)
# rename temporary file to target filename
os.rename(tmp_file, target_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment