diff options
Diffstat (limited to 'exif.py')
-rw-r--r-- | exif.py | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -6,8 +6,8 @@ import exiftool | |||
6 | 6 | ||
7 | 7 | ||
8 | def exif_rename(dir: str): | 8 | def exif_rename(dir: str): |
9 | base_directory = pathlib.Path("C:\\Users\\clarkzjw\\Desktop") | 9 | base_directory = pathlib.Path("/pool1/clarkzjw/Media/Photo") |
10 | directory = str(base_directory.joinpath(dir).absolute()) + "\\" | 10 | directory = str(base_directory.joinpath(dir).absolute()) + "/" |
11 | 11 | ||
12 | files = os.listdir(directory) | 12 | files = os.listdir(directory) |
13 | for file in files: | 13 | for file in files: |
@@ -21,16 +21,16 @@ def exif_rename(dir: str): | |||
21 | 21 | ||
22 | if (file.startswith("IMG_") and (file.endswith(".CR2") or file.endswith(".CR3"))) or \ | 22 | if (file.startswith("IMG_") and (file.endswith(".CR2") or file.endswith(".CR3"))) or \ |
23 | (file.startswith("R") and (file.endswith(".JPG") or file.endswith(".DNG"))) or \ | 23 | (file.startswith("R") and (file.endswith(".JPG") or file.endswith(".DNG"))) or \ |
24 | (file.startswith("PXL_") and file.endswith(".dng")) or \ | 24 | (file.startswith("PXL_") and (file.endswith(".jpg") or file.endswith(".dng"))) or \ |
25 | (file.startswith("DSC") and file.endswith(".ARW")): | 25 | (file.startswith("DSC") and file.endswith(".ARW")): |
26 | with exiftool.ExifToolHelper() as et: | 26 | with exiftool.ExifToolHelper() as et: |
27 | for d in et.get_tags(filename, tags="EXIF:DateTimeOriginal"): | 27 | for d in et.get_tags(filename, tags="EXIF:DateTimeOriginal"): |
28 | timestamp = d["EXIF:DateTimeOriginal"].replace(":", "-") | 28 | if "EXIF:DateTimeOriginal" in d.keys(): |
29 | break | 29 | timestamp = d["EXIF:DateTimeOriginal"].replace(":", "-") |
30 | 30 | filename = directory + timestamp + "-{}.{}".format(old_filename, ext) | |
31 | filename = directory + timestamp + "-{}.{}".format(old_filename, ext) | 31 | print(filename) |
32 | print(filename) | 32 | os.rename(img, filename) |
33 | os.rename(img, filename) | 33 | break |
34 | 34 | ||
35 | 35 | ||
36 | if __name__ == "__main__": | 36 | if __name__ == "__main__": |