omv-bilder-sort.py: --mp4-Modus (Videos nach Jahr/Monat, Namensduplikate ohne MD5 loeschen); Doku aktualisiert
This commit is contained in:
@ -10,7 +10,10 @@ LOG = "/var/log/bilder-sort.log"
|
||||
DRY = "--dry-run" in sys.argv
|
||||
|
||||
IMG = {".jpg", ".jpeg", ".png", ".tif", ".tiff", ".bmp", ".webp", ".heic"}
|
||||
RE1 = re.compile(r"^(\d{4})(\d{2})(\d{2})_\d{6}") # 20250824_195323.jpg
|
||||
VID = {".mp4"}
|
||||
MP4 = "--mp4" in sys.argv # nur Videos, Namensduplikate ohne MD5 loeschen
|
||||
NO_MD5 = MP4
|
||||
RE1 = re.compile(r"^(?:VID_)?(\d{4})(\d{2})(\d{2})_\d{6}(?:_\d{2})?") # 20250824_195323.jpg / VID_20220724_114141.mp4
|
||||
RE2 = re.compile(r"^(\d{4})_(\d{2})_(\d{2})[ _]") # 2025_08_24 1234.JPG
|
||||
|
||||
log = open(LOG, "a", buffering=1)
|
||||
@ -32,7 +35,10 @@ for top in sorted(os.listdir(SRC)):
|
||||
if not os.path.isfile(p):
|
||||
continue
|
||||
ext = os.path.splitext(name)[1].lower()
|
||||
if ext not in IMG:
|
||||
if MP4:
|
||||
if ext not in VID:
|
||||
continue
|
||||
elif ext not in IMG:
|
||||
continue
|
||||
m = RE1.match(name) or RE2.match(name)
|
||||
if not m:
|
||||
@ -52,9 +58,9 @@ for top in sorted(os.listdir(SRC)):
|
||||
for chunk in iter(lambda: fh.read(1 << 20), b""):
|
||||
h.update(chunk)
|
||||
return h.hexdigest()
|
||||
if os.path.getsize(dest) == os.path.getsize(p) and md5(dest) == md5(p):
|
||||
if NO_MD5 or (os.path.getsize(dest) == os.path.getsize(p) and md5(dest) == md5(p)):
|
||||
dup += 1
|
||||
say(f"DUP {p} == {dest}")
|
||||
say(f"DUP {p} ({os.path.getsize(p)}) == {dest} ({os.path.getsize(dest)})")
|
||||
if not DRY:
|
||||
os.remove(p)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user