-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrebuild_directory.py
43 lines (28 loc) · 981 Bytes
/
rebuild_directory.py
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
35
36
37
38
39
40
41
42
43
import exifread
import os
from os import listdir
import time, sys
import tmgshare
import pytz
import datetime
from win32com.propsys import propsys, pscon
source_dir = "Z:\\PhotosMaster"
if (len(sys.argv) == 2):
source_dir = sys.argv[1]
print("Using directory:", source_dir)
input("Press enter to start the process")
with os.scandir(source_dir) as entries:
for file in entries:
if (not file.is_file()): continue
src_file = file.path
dest_file = tmgshare.make_file_by_date_subdir(file.path)
if (not dest_file):
print("file does not have exif:", src_file)
continue
dest_filepath = os.path.join(source_dir, dest_file)
try:
os.rename(src_file, dest_filepath)
print(str.format("Moved {0} to {1}", src_file, dest_filepath))
except:
print("error moving ", src_file)
sys.stdout.flush()