Skip to content

Instantly share code, notes, and snippets.

@szagoruyko
Created June 19, 2018 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szagoruyko/a344d95a87c3f6f280c92991b4939c7d to your computer and use it in GitHub Desktop.
Save szagoruyko/a344d95a87c3f6f280c92991b4939c7d to your computer and use it in GitHub Desktop.
from pathlib import Path
from tqdm import tqdm
import subprocess as sp
import multiprocessing as mp
def convert(nef):
jpg = nef.with_suffix('.JPG')
n = str(nef)
command0 = f'sips -s format jpeg {nef} --out {jpg}'
command1 = f'exiftool -tagsfromfile {nef} -all:all {jpg}'
sp.run(f'{command0} > /dev/null;{command1} > /dev/null', cwd=Path.cwd(), shell=True)
return 0
if __name__ == '__main__':
with open('./nefs.txt', 'r') as f:
tasks = [Path(line.rstrip()) for line in f]
#Run the jobs
with mp.Pool(processes=8) as p:
r = list(tqdm(p.imap(convert, tasks), total=len(tasks)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment