I've a small problem, I have a method in another class that scans a folder and for each file in that folder I need to create new folders according to the date of the files to organize and initiate a new instance, but I'm having trouble on the second part because whatever I try to return it dont seems to work since no new instances are created.
class CPImages:
    def __init__(self, filename):
        self.filename = filename
        self.exif = {}
        self.metadata = {}
    @staticmethod
    def makeCPImage(filename):
        image = CPImages(filename)
        image.loadExif()
        date = photo.getDate()
        if not (os.path.exists(date)):
        #if the folder dont exist, create one and then copy the file
            os.makedirs(date)
            CPImages.copyToFolder(filename, date) 
        else:
        #if the folder exists just copy
            CPImages.copyToFolder(filename, date)
        return CPImages(filename)
Just a bit of more context, the method loadExif() extracts the Exif of the image, the method getDate() turns the date into an usefull format. Here you have the code for searching in the folders
class ImageCollection:
    #Here I search in all folders to extract all files
    def allFiles(folder, fileslist=[], extension='*.jpg*'):
    for obj in os.scandir(folder):
        if obj.is_dir():
            ImageCollection.allFiles(obj)
        if obj.is_file:
            if fnmatch.fnmatch(obj, extension):
                fileslist.append(os.path.join(obj))
            else:
                pass
    return fileslist
    
    #Here I use the files to pass to makeCPImages
    def scanFolder(folder):
    for i in ImageCollection.allFiles(folder):
        CPImages.makeCPImage(i)
ImageCollection.scanFolder('somePath') 
 
    