importglobasgbfromshutilimportcopyfileemotions_list=["neutral","anger","contempt","disgust","fear","happy","sadness","surprise"]emotions_folders=gb.glob("emotions\\*")# Returns a list of all folders with participant numbersdefimageWithEmotionEtraction():forxinemotions_folders:participant="%s"%x[-4:]# store current participant numberforsessionsingb.glob("%s\\*"%x):forfilesingb.glob("%s\\*"%sessions):current_session=files[20:-30]file=open(files,'r')emotion=int(float(file.readline()))# get path for last image in sequence, which contains the emotionsourcefile_emotion=gb.glob("images\\%s\\%s\\*"%(participant,current_session))[-1]# do same for neutral imagesourcefile_neutral=gb.glob("images\\%s\\%s\\*"%(participant,current_session))[0]# Generate path to put neutral imagedest_neut="selected_set\\neutral\\%s"%sourcefile_neutral[25:]# Do same for emotion containing imagedest_emot="selected_set\\%s\\%s"%(emotions_list[emotion],sourcefile_emotion[25:])copyfile(sourcefile_neutral,dest_neut)# Copy filecopyfile(sourcefile_emotion,dest_emot)# Copy fileif__name__=='__main__':imageWithEmotionEtraction()