This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I have very basic knowledge on python and heard chatgtp could be used pretty effectively for at least simpler things like this, so I thought I'd give it a try and to my eye it looks like this should work? All I'm trying to do here is take raw and jpeg photo files from my camera and put them each in a respective folder on my laptop when I run this with an SD card plugged in.
import os import shutil
def copy_files(source_folder, dest_folder_jpg, dest_folder_arw): if not os.path.exists(dest_folder_jpg): os.makedirs(dest_folder_jpg) if not os.path.exists(dest_folder_arw): os.makedirs(dest_folder_arw)
for filename in os.listdir(source_folder):
file_path = os.path.join(source_folder, filename)
if os.path.isfile(file_path):
if filename.lower().endswith('.jpg'):
shutil.copy(file_path, dest_folder_jpg)
elif filename.lower().endswith('.arw'):
shutil.copy(file_path, dest_folder_arw)
source_folder = 'E:/source_folder' dest_folder_jpg = 'C:/destination_folder_jpg' dest_folder_arw = 'C:/destination_folder_arw'
copy_files(source_folder, dest_folder_jpg, dest_folder_arw)
Subreddit
Post Details
- Posted
- 9 months ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/PythonProje...