#!/usr/bin/env python import glob, shutil, sys flights = '/lustre/athorpe/ch4/ORNL_Nature_CH4/Nature_AVng_Flightlines.txt' src = '/lustre/ang/y17/cmf/ort/' #src = '/lustre/ang/y16/cmf/ort/' #src = '/lustre/athorpe/ch4/ORNL_Nature_CH4/Test_From/' dst = '/lustre/athorpe/ch4/ORNL_Nature_CH4/Selected_Renamed_3/' # 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')