-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetect-missing.py
More file actions
24 lines (23 loc) · 928 Bytes
/
detect-missing.py
File metadata and controls
24 lines (23 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
path = os.path.join(os.getcwd(), 'todo')
image_extension = ('.jpg', '.JPG', '.png', '.PNG', '.jpeg')
video_extension = ('.mp4', '.MP4', '.MOV', '.mov')
for root, dirs, files in os.walk(path):
for file in files:
if file.endswith(image_extension):
path = os.path.join(root, file)
pre, ext = os.path.splitext(path)
if os.path.exists(os.path.join(pre + '.avif')):
os.remove(path)
print("Removed", path)
else:
print("Missing:", path)
elif file.endswith(video_extension):
path = os.path.join(root, file)
pre, ext = os.path.splitext(path)
if os.path.exists(os.path.join(pre + '-av1.mkv')):
os.remove(path)
print("Removed", path)
else:
print("Missing:", path)
print("All images and videos converted & removed")