#!/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) print len(lines) # Go through each flight line and generate a list of all the files (including multiple versions) 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) if not "hdr" in file: shutil.copy(file, dst+flight+'_cmf_pub_img') if "hdr" in file: shutil.copy(file, dst+flight+'_cmf_pub_img.hdr') # For four band image, save as the following # if test.find("img.hdr"): # shutil.copy(file,dst+flight+'_cmf_pub_img.hdr') # print('test copy hdr') # elif test.find("img"): # shutil.copy(file,dst+flight+'_cmf_pub_img') # print('test copy img')