# Omeri Photography, LLC # http://www.photography.omeri.net/ # This is a utility that copies client selected image numbers from a raw folder to an in process workflow folder # No warranty is offered or implied with this script. This software is offered as is, and for free. Feel free to modify it. import shutil, os, glob, sys, Image def getSeparator(): #return '/' # linux return '\\' # windows def showUsage(): print("This is a utility that copies client selected image numbers from a raw folder to an in process workflow folder.\n") print("usage: python %(fileName)s searchDirectory 9999[,9999,...] targetDirectory" % {"fileName":sys.argv[0]}) def getFileName(filepath): temp = filepath.split(getSeparator()) return temp[len(temp)-1] def copyFiles(listOfFiles, targetDirectory): #print("Copying the following files to directory [" + targetDirectory + "]: \n" + "\n".join(listOfFiles)) newFile = "" for file in listOfFiles: try: newFile = targetDirectory + getSeparator() + getFileName(file) shutil.copy(file,newFile) print("copied:" + newFile) except IOError as (errno, strerror): print "I/O error({0}): {1}".format(errno, strerror) def searchForFiles(searchDirectory,commaSeparatedImageSearchList): searchFileNameList = commaSeparatedImageSearchList.split(',') listOfFilesInDirectory = glob.glob(os.path.join(searchDirectory,"*")) result = [] for file in listOfFilesInDirectory: for searchFileName in searchFileNameList: if( -1 < file.find(searchFileName)): result.append(file) return result if( 3 >= len(sys.argv)): showUsage() else: searchDirectory = sys.argv[1] targetDirectory = sys.argv[3] commaSeparatedImageSearchList = sys.argv[2] copyFiles(searchForFiles(searchDirectory,commaSeparatedImageSearchList),targetDirectory)