diff options
author | clarkzjw <[email protected]> | 2023-03-17 23:31:11 -0700 |
---|---|---|
committer | clarkzjw <[email protected]> | 2023-03-17 23:31:11 -0700 |
commit | a87e448dfd7697ab2971a44d6669e41304a5e0cf (patch) | |
tree | 662efbef80dc6affc4bf1277b2b0412864342506 | |
parent | 5ec22acf45f812bfdfe844d90764a62c94d47313 (diff) | |
download | Square-a87e448dfd7697ab2971a44d6669e41304a5e0cf.tar.gz |
support RICOH dng
-rw-r--r-- | exif.py | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -5,7 +5,7 @@ import sys | |||
5 | 5 | ||
6 | 6 | ||
7 | def rename(month): | 7 | def rename(month): |
8 | base_directory = pathlib.Path("/mnt/c/Users/clarkzjw/Desktop/") | 8 | base_directory = pathlib.Path("/Users/clarkzjw/Desktop/") |
9 | directory = str(base_directory.joinpath(month).absolute()) + "/" | 9 | directory = str(base_directory.joinpath(month).absolute()) + "/" |
10 | 10 | ||
11 | files = os.listdir(directory) | 11 | files = os.listdir(directory) |
@@ -45,6 +45,28 @@ def rename(month): | |||
45 | print(filename) | 45 | print(filename) |
46 | os.rename(img, filename) | 46 | os.rename(img, filename) |
47 | 47 | ||
48 | elif file.startswith("R") and file.endswith(".DNG"): | ||
49 | filename = directory + file | ||
50 | old_filename = filename.split("/")[-1].split(".")[0] | ||
51 | img = filename | ||
52 | result = subprocess.run(["bash", "-c", "exiftool {} | grep '^Date/Time Original'".format(img)], | ||
53 | stdout=subprocess.PIPE) | ||
54 | timestamp = result.stdout.decode('utf-8').strip("\n").strip("Date/Time Original")[2:].replace(":", "-") | ||
55 | filename = directory + timestamp + "-{}.DNG".format(old_filename) | ||
56 | print(filename) | ||
57 | os.rename(img, filename) | ||
58 | |||
59 | elif file.startswith("R") and file.endswith(".JPG"): | ||
60 | filename = directory + file | ||
61 | old_filename = filename.split("/")[-1].split(".")[0] | ||
62 | img = filename | ||
63 | result = subprocess.run(["bash", "-c", "exiftool {} | grep '^Date/Time Original'".format(img)], | ||
64 | stdout=subprocess.PIPE) | ||
65 | timestamp = result.stdout.decode('utf-8').strip("\n").strip("Date/Time Original")[2:].replace(":", "-") | ||
66 | filename = directory + timestamp + "-{}.JPG".format(old_filename) | ||
67 | print(filename) | ||
68 | os.rename(img, filename) | ||
69 | |||
48 | 70 | ||
49 | if __name__ == "__main__": | 71 | if __name__ == "__main__": |
50 | if len(sys.argv) <= 1: | 72 | if len(sys.argv) <= 1: |