123456789101112131415161718192021222324252627282930313233343536373839 |
- ################################## Selection first file from all folder #######################
- import os
- import shutil
-
- import click
- @click.command()
- @click.argument('eventid', default='')
- def unq1(eventid):
- p1 = r"C:\\Users\\Administrator\\Documents\\AI\\runtimecropimages\\sepration_cluster\\" + eventid + "\\"
- p2 = r"C:\\Users\\Administrator\\Documents\\AI\\runtimecropimages\\unique_1\\" + eventid + "\\"
-
- for path, folders, files in os.walk(p1):
-
- if not files: continue
- try:
- src = os.path.join(path, files[0])
- except IndexError:
- pass
- dst_path = path.replace(p1, '') + os.sep
- # dst_folder = p2 + dst_path
-
- # create the target dir if doesn't exist
- # if not os.path.exists(dst_folder):
- # os.makedirs(dst_folder)
-
- # create dst file with only the first file
- try:
- dst = p2 + files[0]
- except IndexError:
- pass
-
- # copy the file
- shutil.copy2(src, dst)
-
-
-
-
- unq1()
|