aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--exif.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/exif.py b/exif.py
index 7ae3cc5..233ceb5 100644
--- a/exif.py
+++ b/exif.py
@@ -5,7 +5,7 @@ import sys
5 5
6 6
7def rename(month): 7def 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
49if __name__ == "__main__": 71if __name__ == "__main__":
50 if len(sys.argv) <= 1: 72 if len(sys.argv) <= 1:
Powered by cgit v1.2.3 (git 2.41.0)