This function takes two arguments: source_dir
and destination_dir
. It first checks if the source directory exists. If not, it prints an error message and returns. Then, it checks if the destination directory exists. If not, it creates the directory.
Next, it gets a list of all files in the source directory. It iterates over each file and checks if it is an image file by checking its extension. If it is, it copies the file to the destination directory using the shutil.copy()
function.
Finally, it prints a success message when all image files have been copied.
Although these codes and explanations are generated by AI tools, they are manually reviewed for accuracy and work most of the time. Sometimes they're tweaked a bit to make sure they work just right.