-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopy_Images.py
More file actions
executable file
·34 lines (32 loc) · 1.46 KB
/
Copy_Images.py
File metadata and controls
executable file
·34 lines (32 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#This script looks at my list that I removed unwanted idexes from
#Then it copies images that match the ones remaining to a new directory
import time
import os
from shutil import copy2
import pandas as pd
import numpy as np
start_time = time.time()
"""
#Import names from csv file
#Good_Files = pd.read_csv('/home/uahstudent/Documents/Galaxy_Zoo/training_solutions_rev1_OddFeature8.csv')
Good_Files = pd.read_csv('/home/ryan/Documents/Galaxy_Zoo/30Disturbance_50Feature.csv')
#Convert to numpy array
Good_File_Names = Good_Files.iloc[:,0]
Good_File_Names = np.array(Good_File_Names)
"""
###OR###
#Import names from list
Good_File_Names = [659875,660225,660389,662371,662690,662837,664715,666760,677207,683411,684969,685559]
#Change name to x.jpg
Good_File_Names_jpg = []
for i in Good_File_Names:
Good_File_Names_jpg.append('%s.jpg' % i) #add .jpg to end of list so its similar to file names
#Copy files with name in list to a folder within
for i in (Good_File_Names_jpg):
for j in os.listdir('/home/ryan/Documents/Galaxy_Zoo/30Disturbance_50Feature'):#location of images we want to sort through
if j.startswith(i):
os.chdir('/home/ryan/Documents/Galaxy_Zoo/30Disturbance_50Feature')#May need to change this to fit wherever images are stored/coppied from
copy2('%s' % j, '/home/ryan/Documents/Galaxy_Zoo/newhi/')#Location we want to copy images to
#os.chdir('..')
print(j)
print("%s seconds" %(time.time() - start_time))