From d1e1eeb51fd1bc8d902dd6248b6c1bd0ab7a9095 Mon Sep 17 00:00:00 2001 From: clarkzjw Date: Thu, 17 Aug 2023 00:28:22 -0700 Subject: fix paths --- .gitignore | 2 +- exif.py | 18 +++++++++--------- square.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 0a11640..ffc9762 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ +.venv/ .DS_Store __pycache__/ .env .idea/ *.png *.jpg - diff --git a/exif.py b/exif.py index f526683..3e397ad 100644 --- a/exif.py +++ b/exif.py @@ -6,8 +6,8 @@ import exiftool def exif_rename(dir: str): - base_directory = pathlib.Path("C:\\Users\\clarkzjw\\Desktop") - directory = str(base_directory.joinpath(dir).absolute()) + "\\" + base_directory = pathlib.Path("/pool1/clarkzjw/Media/Photo") + directory = str(base_directory.joinpath(dir).absolute()) + "/" files = os.listdir(directory) for file in files: @@ -21,16 +21,16 @@ def exif_rename(dir: str): if (file.startswith("IMG_") and (file.endswith(".CR2") or file.endswith(".CR3"))) or \ (file.startswith("R") and (file.endswith(".JPG") or file.endswith(".DNG"))) or \ - (file.startswith("PXL_") and file.endswith(".dng")) or \ + (file.startswith("PXL_") and (file.endswith(".jpg") or file.endswith(".dng"))) or \ (file.startswith("DSC") and file.endswith(".ARW")): with exiftool.ExifToolHelper() as et: for d in et.get_tags(filename, tags="EXIF:DateTimeOriginal"): - timestamp = d["EXIF:DateTimeOriginal"].replace(":", "-") - break - - filename = directory + timestamp + "-{}.{}".format(old_filename, ext) - print(filename) - os.rename(img, filename) + if "EXIF:DateTimeOriginal" in d.keys(): + timestamp = d["EXIF:DateTimeOriginal"].replace(":", "-") + filename = directory + timestamp + "-{}.{}".format(old_filename, ext) + print(filename) + os.rename(img, filename) + break if __name__ == "__main__": diff --git a/square.py b/square.py index 9e01138..e0fba89 100755 --- a/square.py +++ b/square.py @@ -67,7 +67,7 @@ def drop_shadow(image, offset=(5, 5), background=0xffffff, shadow=0x444444, bord if __name__ == "__main__": files = glob.glob("*") for file in files: - if (file.endswith(".jpg") or file.endswith(".png")) \ + if (file.endswith(".JPG") or file.endswith(".png")) \ and (str.find(file, "result") == -1): names = file.split(".") -- cgit v1.2.3