Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import os
import shutil
data_path = "Negative"
final_output = "2daynegative"
fnames = os.listdir(final_output)
categories = os.listdir(data_path)
#going inside each folder and subfolder manually
for each in categories: #positive and negative folder
folder_path = os.path.join(data_path, each)
img_names = os.listdir(folder_path)
for each2 in img_names: #run through each directory
folder2_path = os.path.join(folder_path, each2)
folder2dir = os.listdir(folder2_path)
for each3 in folder2dir:
folder3_path = os.path.join(folder2_path, each3)
imgdir = os.listdir(folder3_path)
for img in imgdir: #when we get to an image, retrieve only the first two images
img_path = os.path.join(folder3_path,img)
print(img_path)
shutil.copy(img_path, final_output)
break
break