Created
October 3, 2019 11:00
-
-
Save velikodniy/e42e9b028c532022783c4365f411d45b to your computer and use it in GitHub Desktop.
Parallel copy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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