#include #include #include #include #include int main() { DIR *dir; struct dirent *entry; char filepath[1024]; FILE *fp; // Open the directory dir = opendir("/home/arthur/Pictures"); if (dir == NULL) { perror("opendir"); return 1; } // Create a new text file to save the list of images fp = fopen("image_list.txt", "w"); if (fp == NULL) { perror("fopen"); return 1; } while ((entry = readdir(dir)) != NULL) { // Check if the entry is a file and ends with ".jpg" or ".jpeg" if (entry->d_type == DT_REG && strstr(entry->d_name, ".jpg") != NULL) { printf("Found image: %s\n", entry->d_name); fprintf(fp, "%s\n", entry->d_name); } if (entry->d_type == DT_REG && strstr(entry->d_name, ".png") != NULL) { printf("Found image: %s\n", entry->d_name); fprintf(fp, "%s\n", entry->d_name); } } // Close the directory and text file closedir(dir); fclose(fp); return 0; }