Briefly, I'm looking at getting the code below to execute faster. I have 100k images to go through. I'm running a query against MySQL, looping through results and then running exiftool against an image, then moving it.I started running it and it quickly became evident it wouldn't be a quick thing :-(import mysql.connectorimport oscnx = mysql.connector.connect(user='root',database='database', password='password')cursor = cnx.cursor()query = (SELECT post_title,Event,File,Name from a order by File)cursor.execute(query)def shellquote(s):    return s.replace(', )for (post_title, Event,File,Name) in cursor:    olddir = r'/home/alan/Downloads/OLD/'    newdir = r'/home/alan/Downloads/NEW/' + post_title    oldfile = olddir + File    newfile = newdir + /+File    if not os.path.exists(newfile):        os.makedirs(newfile)    if os.path.isfile(oldfile):         print  > PROCESSING:  + oldfile        os.system(exiftool -q +shellquote(oldfile)+ -xmp:title='+shellquote(post_title)+')        os.system(exiftool -q +shellquote(oldfile)+ -xmp:description='+shellquote(Name)+ courtesy of https://www.festivalflyer.com')        os.system(exiftool -q +shellquote(oldfile)+ -description='+shellquote(Name)+ courtesy of https://www.festivalflyer.com')        os.rename(oldfile, newfile)cursor.close()cnx.close()I tried using subprocess but for whatever reason, I didn't get it to run. Any advice is welcome.I suppose I could move the 3 lines of exiftool commands to just one and pass multiple arguments. I also saw -stay_open as an option to exiftool but not sure how to apply it
Loop through database and run shell commands with Python and exiftool
python;performance;python 2.7;mysql