View Full Version : How do I sort by file size/date of creation/date modified etc in python?
April 7th, 2007, 10:24 AM
I want to make a small script that picks out every 100th (or whatever) photo, by the creation date, from a folder and put the photos in a new folder. I don't think there will be any trouble copying over the files etc, but being able to sort through them via their properties has me stumped.
So is there some function, or some other way, which lets me find and read the properties of each file?
April 7th, 2007, 11:27 AM
You need os.stat
flist = glob.glob(sys.argv)
for i in range(len(flist)):
statinfo = os.stat(flist[i])
flist[i] = flist[i],statinfo.st_size,statinfo.st_ctime
print 'sorted by size:',flist
print 'sorted by creation date:',flist
April 7th, 2007, 12:08 PM
beautiful, thanks for that. Now I just have to figure out the easiest way to sort 30-40 thousand photos.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.