Skip to content

Commit 0104ddf

Browse files
Create imgsort.py
Added a script to sort images in a directory by time using python!
1 parent e7bd769 commit 0104ddf

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import os
2+
3+
import shutil
4+
5+
from PIL
6+
import Image
7+
8+
import PIL
9+
10+
import os.path, time
11+
12+
from datetime
13+
import datetime
14+
15+
lis = []
16+
17+
old = ""
18+
19+
new = ""
20+
21+
lis = os.listdir('C:\New folder\\')
22+
23+
lis.sort()
24+
25+
for x in lis:
26+
27+
if x == __file__:
28+
29+
continue
30+
31+
if x == 'Thumbs.db':
32+
33+
continue
34+
35+
print "created: %s" % time.ctime(os.path.getctime(x))
36+
37+
datestring = time.ctime(os.path.getmtime(x))
38+
39+
dt = datetime.strptime(datestring, '%a %b %d %H:%M:%S %Y')
40+
41+
# old = str(dt.month) + '-' + str(dt.day) + '-' + str(dt.year)
42+
43+
#
44+
if old == new:
45+
46+
#shutil.move(x, destinationDir)
47+
48+
#
49+
else :
50+
51+
#new = str(dt.month) + '-' + str(dt.day) + '-' + str(dt.year)
52+
53+
destinationDir = 'C:\New folder\\' + str(dt.month) + '-' + str(dt.day) + '-' + str(dt.year)
54+
55+
if not os.path.exists(destinationDir):
56+
57+
os.makedirs(destinationDir)
58+
59+
shutil.move(x, destinationDir)

0 commit comments

Comments
 (0)