(path_in, path_out, limit, delete)
Pick a random set of jpg files and copy them to an other folder.

  Args:
    path_in: the folder that contains the files
    path_out: the folder to export the picked files
    limit: number of file to pick
    delete: if true, will delete the original files

  Returns:
    nothing

  Raises:
    nothing
Pick a random set of jpg files and copy them to an other folder.
Pick a random set of jpg files and copy them to an other folder .
def random_pick(path_in, path_out, limit, delete):
  """Pick a random set of jpg files and copy them to an other folder.

  Args:
    path_in: the folder that contains the files
    path_out: the folder to export the picked files
    limit: number of file to pick
    delete: if true, will delete the original files

  Returns:
    nothing

  Raises:
    nothing
  """
  if path_in == path_out:
    print('path in == path out, that is not allowed, quiting')
    sys.exit()

  path = '{}/*'.format(path_in)
  print('looking for all files in', path)
  files = glob.glob(path)
  file_count = len(files)
  print('found ', file_count, 'files')
  if limit > 0:
    print('will use limit of', limit, 'files')
    random.shuffle(files)
    files = files[:limit]

  i = 0
  for image_file in files:
    i += 1
    basename = ntpath.basename(image_file)
    file_out = os.path.join(path_out, basename)

    try:
      if delete:
        print(i, '/', limit, '  moving', image_file, 'to', file_out)
        shutil.move(image_file, file_out)
      else:
        print(i, '/', limit, '  copying', image_file, 'to', file_out)
        shutil.copyfile(image_file, file_out)
    except:  # pylint: disable=bare-except
      print("""can't pick file""", image_file, 'to', file_out)
def random_pick ( path_in , path_out , limit , delete ) : if path_in == path_out : print ( 'path in == path out, that is not allowed, quiting' ) sys . exit ( ) path = '{}/*' . format ( path_in ) print ( 'looking for all files in' , path ) files = glob . glob ( path ) file_count = len ( files ) print ( 'found ' , file_count , 'files' ) if limit > 0 : print ( 'will use limit of' , limit , 'files' ) random . shuffle ( files ) files = files [ : limit ] i = 0 for image_file in files : i += 1 basename = ntpath . basename ( image_file ) file_out = os . path . join ( path_out , basename ) try : if delete : print ( i , '/' , limit , '  moving' , image_file , 'to' , file_out ) shutil . move ( image_file , file_out ) else : print ( i , '/' , limit , '  copying' , image_file , 'to' , file_out ) shutil . copyfile ( image_file , file_out ) except : # pylint: disable=bare-except print ( """can't pick file""" , image_file , 'to' , file_out )