1 from os import listdir as ls
2 from os.path import join
3 from shutil import move as mv
6 def move(indir, outdir, n):# move n ordered files from indir to outdir
9 # print(join(indir, filename), join(outdir, filename))
10 pathlib.Path(outdir).mkdir(parents=True, exist_ok=True)
11 mv(join(indir, filename), join(outdir, filename))
13 if __name__ == '__main__':
15 move('./train/infarctus', './sample/train/infarctus', 1000) # move 1000 ordered files from param 1 to param 2
16 move('./train/noinfarctus', './sample/train/noinfarctus', 1000)
17 move('./train/infarctus', './sample/valid/infarctus', 300)
18 move('./train/noinfarctus', './sample/valid/noinfarctus', 300)