Skip to content

Instantly share code, notes, and snippets.

@artschwagerb
Created December 4, 2014 15:14
Show Gist options
  • Save artschwagerb/0aa07f31c44b11ee4eb7 to your computer and use it in GitHub Desktop.
Save artschwagerb/0aa07f31c44b11ee4eb7 to your computer and use it in GitHub Desktop.
Destiny idlink.txt creation script
import os
image_folder = '/Users/brian/Desktop/Student_Images'
image_linkfile = image_folder+'/idlink.txt'
f = open(image_linkfile,'wb')
for filename in os.listdir(image_folder):
filepath = os.path.join(image_folder,filename)
if os.path.isfile(filepath):
#filename becomes a list of filename parts: [0] name, [-1] extension
filename = os.path.splitext(filename)
if '.JPG' in filename[-1]:
#Rename .JPG to .jpg
newname = filepath.replace('.JPG', '.jpg')
os.rename(filepath, newname)
if '.jpg' in filename[-1]:
#Write to File
f.write('"' + filename[0] + '","' + ''.join(filename) + '"\n')
print "File Created " + image_linkfile
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment