-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetCheese.py
More file actions
27 lines (20 loc) · 833 Bytes
/
setCheese.py
File metadata and controls
27 lines (20 loc) · 833 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
25
26
27
import os
from PIL import Image
# Get the user's home directory and the desktop folder
home_dir = os.path.expanduser(r"C:\Users\FRC")
desktop_dir = os.path.join(home_dir, "Desktop")
# Set the directory containing the images
image_dir = r"C:\Users\FRC\Desktop\Cheese-main\dataset\cheese"
# Iterate over the files in the directory
for filename in os.listdir(image_dir):
# Filter out non-image files
if not filename.endswith((".jpg", ".jpeg", ".png", ".gif")):
continue
# Load the image
image_path = os.path.join(image_dir, filename)
image = Image.open(image_path)
# Save the image to the desktop folder
desktop_path = os.path.join(desktop_dir, filename)
image.save(desktop_path)
# Optional: print a message indicating that the file was saved
print(f"Saved {filename} to desktop")