#!/usr/bin/env python import glob, shutil, sys flights = '/lustre/athorpe/ch4/ORNL_Nature_CH4/test_listfile.txt' src = '/lustre/athorpe/ch4/ORNL_Nature_CH4/Test_From/' dst = '/lustre/athorpe/ch4/ORNL_Nature_CH4/Test_To/' #dst_test = '/lustre/athorpe/ch4/ORNL_Nature_CH4/Test_To/ang20170309t194008_cmf' # Read in text file of flights with open(flights, "r") as fd: lines = fd.read().splitlines() print ('lines:',lines) # Go through each flight line and generate a list of all the files (including multiple versions) print len(lines) #for f in range(0,len(lines)): # flight=lines[f] # print('flight:',flight) # print('f:',f) # for file in sorted(glob.glob(src+flight+'*')): # print(file) # shutil.copy(file, dst) # print('test') for f in range(0,len(lines)): flight=lines[f] print('flight:',flight) print('f:',f) for file in sorted(glob.glob(src+flight+'*')): print('file:',file) #Seperate path to isolate the name test=file.split("/")[-1] print('split:',test) # For four band image, save as the following # if test.find("hdr"): # shutil.copy(file, dst+flight+'_cmf_pub_img.hdr') # print('test copy hdr') # elif test.find("hdr"):: # shutil.copy(file, dst+flight+'_cmf_pub_img') # print('test copy img') if not "hdr" in file shutil.copy(file, dst+flight+'_cmf_pub_img') #for file in vendors: # for f in (glob.glob(file)): # if "apple" in f: # if apple in name, move to new apple dir # shutil.move(f, new_apple_dir) # else: # shutil.move(f, new_intel_dir) # else move to intel dir #Remove last few lines of header #readFile = open(file) #lines = readFile.readlines() #readFile.close() #w = open(file,'w') #w.writelines([item for item in lines[:-10]]) #w.close() # For header file, save as the following #else: #shutil.copy(file, dst+flight+'_cmf_pub_img') #file_sel=file[-2:] #shutil.copy(file, dst) #print('test') #print('fil_sel:',file_sel) # Read in text file of flights #with open(flights, "r") as fd: # lines = fd.read().splitlines() #print ('lines:',lines) # Go through each flight line and generate a list of all the files (including multiple versions) #print len(lines) #for f in range(0,len(lines)-1): # flight=lines[f] # print('flight:',flight) # print('f:',f) #for file in glob.glob(src+'ang20170309t191207*'): # shutil.move(file, dst) #for n in files: # print('n:',n) # path='/lustre/athorpe/ch4/ORNL_Nature_CH4/Test_From/'+str(flight)+'*' # glob.glob(path) #for file in glob.glob(src+flight+'*'): #for file in glob.glob(src+'ang20170309t191207*'): # shutil.move(file, dst) # a list of file types #vendors =['path_to_dir/apple*', 'path_to_dir/intel*'] #for file in vendors: # for f in (glob.glob(file)): # if "apple" in f: # if apple in name, move to new apple dir # shutil.move(f, new_apple_dir) # else: # shutil.move(f, new_intel_dir) # else move to intel dir