Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A Python script to organize digital photos' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A Python script to organize digital photos
Authored by: aubreyapple on Apr 02, '03 11:32:55AM

It looks like the script is incomplete, was truncated by hints, or I do not know what I am doing. It seems to end with:

if len(month)



[ Reply to This | # ]
A Python script to organize digital photos
Authored by: dimus on Apr 02, '03 02:37:11PM

Yes, you are right! Somehow the script got truncated, I'll try again here



_____START_OF_THE_SCRIPT_BELOW_THIS_LINE_____
#!/usr/bin/env python

import os, sys, time

#Change these directories to your own settings
picturesDownloadDirectory="/Users/dimus/Pictures"
newPhotosDirectory="/Users/dimus/newPhotos"


#Don't change anything below this line:
#_________________________________________________________
os.chdir(picturesDownloadDirectory)
files=os.listdir(os.curdir)
pics=[]

for i in files:
if i [-3:].upper()=="JPG":
pics.append(i)

print "Enter the name of the pictures: ",
name=raw_input()

local_time=time.localtime(time.time())
year=str(local_time[0])[2:]
month=str(local_time[1])
if len(month)<2: month='0'+ month
day=str(local_time[2])
if len(day)<2: day='0' + day
timestring=year+month+day
count=0
for i in pics:
count=count+1
num=''
if count<10:
num="00"+str(count)
elif count<100:
num="0"+str(count)
else:
num=str(count)
name=name.replace(' ','_')
file="%s/%s-%s-%s.%s" % (newPhotosDirectory,timestring,name,num,i[-3:].lower())
print "%s is moving" % file
os.system("mv %s %s" % (i,file))


#_____END_OF_THE_SCRIPT_____



[ Reply to This | # ]