From 0e4999b6f33f3e0a4c64dd2609a172a4e594572a Mon Sep 17 00:00:00 2001 From: Andreas Balogh Date: Mon, 10 Apr 2023 21:13:53 +0200 Subject: [PATCH] unknown --- .vscode/settings.json | 55 +++++++++++++++++++++++++++++++++++++- ren_triage.py | 13 ++++++--- set_m4v_mtime.py | 10 +++---- set_mtime_from_filename.py | 40 +++++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 10 deletions(-) create mode 100644 set_mtime_from_filename.py diff --git a/.vscode/settings.json b/.vscode/settings.json index 3012468..ec6964a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,56 @@ { - "python.pythonPath": "C:\\Apps\\Python310\\python.exe" + "code-runner.executorMap": { + + "javascript": "node", + "java": "cd $dir && javac $fileName && java $fileNameWithoutExt", + "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", + "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", + "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", + "php": "php", + "python": "C:\\Apps\\Python3\\python.exe -u", + "perl": "perl", + "perl6": "perl6", + "ruby": "ruby", + "go": "go run", + "lua": "lua", + "groovy": "groovy", + "powershell": "powershell -ExecutionPolicy ByPass -File", + "bat": "cmd /c", + "shellscript": "bash", + "fsharp": "fsi", + "csharp": "scriptcs", + "vbscript": "cscript //Nologo", + "typescript": "ts-node", + "coffeescript": "coffee", + "scala": "scala", + "swift": "swift", + "julia": "julia", + "crystal": "crystal", + "ocaml": "ocaml", + "r": "Rscript", + "applescript": "osascript", + "clojure": "lein exec", + "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt", + "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt", + "racket": "racket", + "scheme": "csi -script", + "ahk": "autohotkey", + "autoit": "autoit3", + "dart": "dart", + "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt", + "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt", + "haskell": "runhaskell", + "nim": "nim compile --verbosity:0 --hints:off --run", + "lisp": "sbcl --script", + "kit": "kitc --run", + "v": "v run", + "sass": "sass --style expanded", + "scss": "scss --style expanded", + "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css", + "FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", + "fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", + "fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", + "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt", + "sml": "cd $dir && sml $fileName" + } } \ No newline at end of file diff --git a/ren_triage.py b/ren_triage.py index ee39ad9..c917a18 100644 --- a/ren_triage.py +++ b/ren_triage.py @@ -19,7 +19,7 @@ DRY_RUN = False fileidx = defaultdict(int) -CAMERAS = ("GoPro Hero3+", "Ricoh Theta V", "Ricoh Theta S", "Sony a5100", "Sony a65", "Sony a68", "Sony TRV-25E", "Fuji Finepix Real 3D W3", "DJI Mini 2", "Mobile Media") +CAMERAS = ("GoPro Hero3+", "Ricoh Theta V", "Ricoh Theta S", "Sony a5100", "Sony a65", "Sony a68", "Sony TRV-25E", "Fuji Finepix Real 3D W3", "DJI Mini 2", "Samsung Galaxy A40", "Samsung Galaxy A41") def recurse(dir, md, camera=None): @@ -45,7 +45,7 @@ def recurse(dir, md, camera=None): author = "ab" mtime = fp.stat().st_mtime rawdt = dt.datetime.fromtimestamp(mtime) - if fp.suffix.lower() == ".jpg": + if fp.suffix.lower() in [".jpg"]: try: exif_dict = piexif.load(str(fp)) idto = exif_dict["Exif"][piexif.ExifIFD.DateTimeOriginal].decode("ascii") @@ -56,8 +56,8 @@ def recurse(dir, md, camera=None): try: model = exif_dict["0th"][piexif.ImageIFD.Model].decode("ascii") except: + print(exif_dict) model = None - pass use_camera = False if model == 'Canon EOS 5D': print(f"{fp.name} scanned photo, use directory date") @@ -69,6 +69,13 @@ def recurse(dir, md, camera=None): author = "jb" if model == 'ASUS_Z00ED': author = "sb" + if model == 'SM-A405FN': + author = "ab" + if model == 'SM-A415F' or camera == "Samsung Galaxy A41": + author = "kb" + elif fp.suffix.lower() == ".heic": + use_camera = False + author = "kb" elif fp.suffix.upper() == ".ARW": use_camera = False elif fp.suffix.upper() == ".MRW": diff --git a/set_m4v_mtime.py b/set_m4v_mtime.py index 61d8e2b..734a5dd 100644 --- a/set_m4v_mtime.py +++ b/set_m4v_mtime.py @@ -1,4 +1,4 @@ -#!python3 +#!python # set mtime for handbrake mp4 files from filename @@ -8,8 +8,6 @@ from pathlib import Path import datetime as dt -import piexif -from collections import defaultdict import re import os @@ -23,10 +21,10 @@ def rename(old, new): else: print(f"skipped {old.name}, {new.name}, already exists") -src = Path(r'D:\Videos') +# src = Path(r'D:\Videos') -for raw in src.glob("*.m4v"): - mo = re.match("(?P[^-]*)-(?P
\S*)-(?P[^-]*)(-\S+)?.m4v", raw.name) +for raw in src.glob("*.mp4"): + mo = re.match("(?P[^-]*)-(?P
\S*)-(?P[^-]*)(-\S+)?.mp4", raw.name) if mo is None: print(f"skipped {raw.name}, no match") continue diff --git a/set_mtime_from_filename.py b/set_mtime_from_filename.py new file mode 100644 index 0000000..cb17670 --- /dev/null +++ b/set_mtime_from_filename.py @@ -0,0 +1,40 @@ +#!python + +# set mtime for handbrake mp4 files from filename + +# https://github.com/hMatoba/Piexif +# http://ce3wiki.theturninggate.net/doku.php?id=file_name_convention +# destination: // /ab---.jpg + +from pathlib import Path +import datetime as dt +import re +import os + +DRY_RUN = False + +def rename(old, new): + print(old.name, "->", new.name) + if not DRY_RUN: + if not new.exists(): + old.rename(new) + else: + print(f"skipped {old.name}, {new.name}, already exists") + +# src = Path(r'D:\Videos') +src = Path(r"D:\MediaLibrary\Pictures\2022\20220831 Urlaub Cote d'Azur") + +for raw in src.glob("*pano.jpg"): + mo = re.match("(?P[^-]*)-(?P
\S*)-(?P[^-]*)(-\S+)?.jpg", raw.name) + if mo is None: + print(f"skipped {raw.name}, no match") + continue + md = mo.groupdict() + rawdt = dt.datetime.strptime(md['dt'],"%Y%m%d-%H%M%S") + mtime = rawdt.timestamp() + atime = raw.stat().st_atime + print(f"setting {raw.name} to {rawdt}") + if not DRY_RUN: + os.utime(raw, (atime, mtime)) + # fn = f"{md['author'].lower()}-{md['dt']}-{md['model']}{raw.suffix}" + # rename(raw, raw.parent / fn)