diff options
Diffstat (limited to 'exif.py')
-rw-r--r-- | exif.py | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -3,10 +3,12 @@ import pathlib | |||
3 | import platform | 3 | import platform |
4 | import sys | 4 | import sys |
5 | import exiftool | 5 | import exiftool |
6 | from datetime import datetime, timedelta | ||
6 | 7 | ||
8 | offset = 1 | ||
7 | 9 | ||
8 | def exif_rename(dir: str): | 10 | def exif_rename(dir: str): |
9 | base_directory = pathlib.Path("/pool1/clarkzjw/Media/Photo") | 11 | base_directory = pathlib.Path("/mnt/pool1/Media/Photo") |
10 | directory = str(base_directory.joinpath(dir).absolute()) + "/" | 12 | directory = str(base_directory.joinpath(dir).absolute()) + "/" |
11 | 13 | ||
12 | files = os.listdir(directory) | 14 | files = os.listdir(directory) |
@@ -26,7 +28,13 @@ def exif_rename(dir: str): | |||
26 | with exiftool.ExifToolHelper() as et: | 28 | with exiftool.ExifToolHelper() as et: |
27 | for d in et.get_tags(filename, tags="EXIF:DateTimeOriginal"): | 29 | for d in et.get_tags(filename, tags="EXIF:DateTimeOriginal"): |
28 | if "EXIF:DateTimeOriginal" in d.keys(): | 30 | if "EXIF:DateTimeOriginal" in d.keys(): |
29 | timestamp = d["EXIF:DateTimeOriginal"].replace(":", "-") | 31 | #serial = int(filename.split("/")[-1].split(".")[0][1:]) |
32 | datetime_object = datetime.strptime(d["EXIF:DateTimeOriginal"], '%Y:%m:%d %H:%M:%S') | ||
33 | #if serial > 8630: | ||
34 | # datetime_object += timedelta(hours=10) | ||
35 | #else: | ||
36 | # datetime_object += timedelta(hours=offset) | ||
37 | timestamp = str(datetime_object).replace(":", "-") | ||
30 | filename = directory + timestamp + "-{}.{}".format(old_filename, ext) | 38 | filename = directory + timestamp + "-{}.{}".format(old_filename, ext) |
31 | print(filename) | 39 | print(filename) |
32 | os.rename(img, filename) | 40 | os.rename(img, filename) |