Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import os
import subprocess
import urllib
import sys
# you need to pass the _list.txt file as 1st argument.
# python 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
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
You can’t perform that action at this time.