-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete_copied_album_photos.py
32 lines (25 loc) · 1.19 KB
/
delete_copied_album_photos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
import csv
def delete_photos(source_dir, csv_dir):
for csv_file in os.listdir(csv_dir):
if csv_file.endswith('.csv'):
csv_path = os.path.join(csv_dir, csv_file)
with open(csv_path, 'r') as f:
csv_reader = csv.reader(f)
next(csv_reader) # Skip the header row
for row in csv_reader:
if row:
image_filename = row[0]
file_path = os.path.join(source_dir, image_filename)
if os.path.exists(file_path):
try:
os.remove(file_path)
print(f"Deleted: {image_filename}")
except PermissionError:
print(f"Permission denied: Unable to delete {image_filename}")
else:
print(f"File not found: {image_filename}")
if __name__ == "__main__":
photos_dir = './Photos_All/Photos' # Where your photos are
csv_dir = "icloud_backup/Albums" # Usually found in one of the iCloud Photos Part X directories
delete_photos(photos_dir, csv_dir)