From a87e448dfd7697ab2971a44d6669e41304a5e0cf Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Fri, 17 Mar 2023 23:31:11 -0700 Subject: support RICOH dng --- exif.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/exif.py b/exif.py index 7ae3cc5..233ceb5 100644 --- a/exif.py +++ b/exif.py @@ -5,7 +5,7 @@ import sys def rename(month): - base_directory = pathlib.Path("/mnt/c/Users/clarkzjw/Desktop/") + base_directory = pathlib.Path("/Users/clarkzjw/Desktop/") directory = str(base_directory.joinpath(month).absolute()) + "/" files = os.listdir(directory) @@ -45,6 +45,28 @@ def rename(month): print(filename) os.rename(img, filename) + elif file.startswith("R") and file.endswith(".DNG"): + filename = directory + file + old_filename = filename.split("/")[-1].split(".")[0] + img = filename + result = subprocess.run(["bash", "-c", "exiftool {} | grep '^Date/Time Original'".format(img)], + stdout=subprocess.PIPE) + timestamp = result.stdout.decode('utf-8').strip("\n").strip("Date/Time Original")[2:].replace(":", "-") + filename = directory + timestamp + "-{}.DNG".format(old_filename) + print(filename) + os.rename(img, filename) + + elif file.startswith("R") and file.endswith(".JPG"): + filename = directory + file + old_filename = filename.split("/")[-1].split(".")[0] + img = filename + result = subprocess.run(["bash", "-c", "exiftool {} | grep '^Date/Time Original'".format(img)], + stdout=subprocess.PIPE) + timestamp = result.stdout.decode('utf-8').strip("\n").strip("Date/Time Original")[2:].replace(":", "-") + filename = directory + timestamp + "-{}.JPG".format(old_filename) + print(filename) + os.rename(img, filename) + if __name__ == "__main__": if len(sys.argv) <= 1: -- cgit v1.2.3