File size: 915 Bytes
8b4081b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from os import makedirs
from os import listdir
from os.path import join
from shutil import copy
from concurrent.futures import ThreadPoolExecutor

NUM_FILES = 5000


# +

 # copy a file from source to destination
def copy_file(src_path, dest_dir):
    # copy source file to dest file
    dest_path = copy(src_path, dest_dir)
    # report progress
    print(f'.copied {src_path} to {dest_path}')
    
def main(src='../../AVA_src/images/images/', dest='../../AVA_src/images_5k/'):
    # create the destination directory if needed
    makedirs(dest, exist_ok=True)
    # create full paths for all files we wish to copy
    files = [join(src,name) for name in listdir(src)][:NUM_FILES]
    print("Files: ",files)
    # create the thread pool
    with ThreadPoolExecutor(10) as exe:
        # submit all copy tasks
        _ = [exe.submit(copy_file, path, dest) for path in files]

if __name__ == '__main__':
    main()