Created
December 4, 2014 15:14
-
-
Save artschwagerb/0aa07f31c44b11ee4eb7 to your computer and use it in GitHub Desktop.
Destiny idlink.txt creation script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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