Skip to content

Instantly share code, notes, and snippets.

@velikodniy
Created October 3, 2019 11:00
Show Gist options
  • Save velikodniy/e42e9b028c532022783c4365f411d45b to your computer and use it in GitHub Desktop.
Save velikodniy/e42e9b028c532022783c4365f411d45b to your computer and use it in GitHub Desktop.
Parallel copy
from pathlib import Path
import shutil
from tqdm import tqdm
from joblib import Parallel, delayed
def pcopy(dir_in, dir_out, files_list, processes=8):
dir_in = Path(dir_in)
dir_out = Path(dir_out)
copy_list = [
(dir_in / file, dir_out / file)
for file in files_list
]
def cp(pin, pout):
pout.parent.mkdir(parents=True, exist_ok=True)
shutil.copy(pin, pout)
Parallel(processed)(delayed(cp)(pin, pout) for pin, pout in tqdm(copy_list))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment