mcetl.file_organizer

Provides GUIs to find files containing combinations of keywords and move files.

@author: Donald Erb Created on Sep 2, 2019

Module Contents

Functions

file_finder

Finds files that match the given keywords and file type using a GUI.

file_mover

Takes in a list of file paths and moves a copy of each file to the new folder.

manual_file_finder

Allows manual selection for the files for the selected samples and datasets.

mcetl.file_organizer.file_finder(file_directory=None, file_type=None, num_files=None)

Finds files that match the given keywords and file type using a GUI.

Parameters
  • file_directory (str) -- String for the topmost folder under which all files are searched.

  • file_type (str) -- The file extension that is being searched, eg. csv, txt, pdf.

  • num_files (int) -- The default maximum and minimum number of files to be associated with each search term.

Returns

output_list -- A nested list of lists containing the file locations as strings for the files that matched the search term. len(output_list) is equal to the number of datasets, len(output_list[i]) is equal to the number of unique keywords for dataset i, and len(outupt_list[i][j]) is equal to the number of files for dataset i and unique keyword j.

Return type

list

mcetl.file_organizer.file_mover(file_list, new_folder=None, skip_same_files=True)

Takes in a list of file paths and moves a copy of each file to the new folder.

Parameters
  • file_list (list, tuple, or str) -- A list of strings corresponding to file paths, all of which will have their copies moved.

  • new_folder (str or Path) -- The folder to move all of copies of the files in the file_list into.

  • skip_same_files (bool) -- If True, will not move any copied files if they already exist in the destination folder; if False, will rename the copied file and move it to the destination folder.

Returns

new_folder -- The string of the destination folder location.

Return type

str

mcetl.file_organizer.manual_file_finder(file_type=None)

Allows manual selection for the files for the selected samples and datasets.

Parameters

file_type (str, optional) -- The desired file extension for all files.

Returns

files -- A list of lists of lists of file paths. Each list of lists corresponds to a dataset, and each internal list corresponds to a sample in the dataset.

Return type

list(list(list(str)))