0

I have in my project a folder with multiple subfolders, in each of them there is some images. I want to make multiples carousels and each carousel will use images for each subfolders. How can I loopt through each of them to import those images ? I've been trying to find a good way, but I did not succeed. I'm writting this pythonlike example to show the idea in my mind:

parent_directory = 'path to the directory'
for dir in parent_directory:
    #dir would be subdirectory name
    files = dir.get_files()#any data structure containing all files names

    for f in files:
        full_file_path = parent_directory/dir/f
        # and them with this full path i would import the image
  • 3
    Since React runs in the browser there's no way it can access the filesystem to read the folder structure. You could create a script to run through webpack to auto create a js file importing all the images, but I think this is not a good option. It's hard to create and maintin. I would recomend you to creat a js file were you manually import all images – Mark E Feb 06 '23 at 18:39

0 Answers0