import os
os.mkdir('grouped')
for i in range(1,26):
    os.mkdir('grouped/%02d' % i)
from glob import glob
for i in range(1,1001):
    path = glob('series0079-Body/img%04d--*.dcm' % i)[0]
    g = '%02d' % (1 + ((i-1)//40))
    filename = path.split('/')[1]
    os.link(path, f'grouped/{g}/{filename}')
