I am writing a short script in python that scans the list of folders for image files and then reorganizes them.
One of the possible ways to organize them that I want to have is the date they were created.
I'm currently trying to read the image creation date as follows
import os.path, time
f = open("hi.jpg")
data = f.read()
f.close()
print "last modified: %s" % time.ctime(os.path.getmtime(f))
print "created: %s" % time.ctime(os.path.getctime(f))
But I get an error
Traceback (most recent call last):
File "TestEXIFread.py", line 6, in <module>
print "last modified: %s" % time.ctime(os.path.getmtime(f))
File "/usr/lib/python2.7/genericpath.py", line 54, in getmtime
return os.stat(filename).st_mtime
TypeError: coercing to Unicode: need string or buffer, file found
Can someone tell me what that means?
source
share