-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmove_pics.py
More file actions
34 lines (32 loc) · 819 Bytes
/
move_pics.py
File metadata and controls
34 lines (32 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
Crawling all the pictures in the file system
and move them to mentioned folder in year wise fasion.
"""
import exifread
from os.path import walk
from os import path
import os
import shutil
from glob import glob
file_list = {}
dest = 'D:\Pictures\Others'
def process_pics(args, dir, fnames):
"""
copies Files in the desired folders
"""
for file in fnames:
if file.endswith('.jpg'):
file = path.join(dir, file)
f = open (file, 'rb')
exif = exifread.process_file(f)
f.close()
if 'Image DateTime' in exif:
dirname = str(exif['Image DateTime'])[:4]
destination = os.path.join(dest, dirname)
if not path.exists(destination):
os.makedirs(destination)
shutil.copy2(file, destination)
dirs = ['C:/','D:/','E:/']
for dir in dirs:
walk(dir, process_pics, None)
print 'Done'