Function sortery::tools::sort::get_sorting_results [−][src]
fn get_sorting_results(
source: &File,
target: &File,
date_format: &str,
date_type: &str,
preserve_name: &bool,
exclude_type: (&str, bool),
only_type: (&str, bool)
) -> (usize, Vec<File>, Vec<File>)Expand description
The main sorting algorithm; this checks files for validity and shows the progress bar.
The parameters are as follows:
-
sourceis the directory from which to get all the files to sort. -
targetis the directory into which to sort all the files. -
date_formatis the date format with which to rename the files. It shares the formatting rules with thechrono::format::strftimemodule. -
date_typeis the date to sort the files by; one of"c"(created),"a"(accessed), or"m"modified. Note that creation time is not available on all filesystems. -
preserve_name, if set totrue, will add the original filename after the date, separated by a space. For example, sorting a filetest.txtwithpreserve_name=truewill renametest.txtto2021-04-21 06h34m02s test.txt -
exclude_typeis atuplecontaining two items. One is astrrepresenting the extension of a file type to exclude from sorting. For example, if"jpg"is passed, all files ending in.jpgwill be ignored during sorting. The other item is abooltelling whetherexclude_typeshould take effect or not. -
only_typeistuplecontaining two items. One is astrrepresenting the extension of a file type to exclusively sort. For example, if"jpg"is passed, only files ending in.jpgwill be sorted; all others will be ignored. Overrides theexclude_typeoption. The other item is abooltelling whetheronly_typeshoud take effect or not.
This returns a three-item tuple containing: a usize representing the
number of items to be sorted, a Vec<File> of the old file names, and
a Vec<File> of the new file names. Each item in the old file names
corresponds with the item of the same index in the new file names. So
old_names[0] will be renamed to new_names[0], old_names[1] will be
renamed to new_names[1], etc.