diff --git a/src/files.rs b/src/files.rs index 9c2b550..071212a 100644 --- a/src/files.rs +++ b/src/files.rs @@ -183,7 +183,7 @@ pub fn scan_from_walkdir( } /// Scans a given directory with [`WalkDir`], filters with [`wanted_file`], checks for errors, and returns a vector of -/// [DirEntry]s. +/// [`DirEntry`]s. pub fn scan_directory( dirs: &Path, exts: Option<&BTreeSet<&str>>, diff --git a/src/formats.rs b/src/formats.rs index a21403c..5bb4d75 100644 --- a/src/formats.rs +++ b/src/formats.rs @@ -316,7 +316,7 @@ impl FormatSteps for Text { smart_write( f, // writablesln![Newline, "Processed ", (entries.len().to_string().as_str()), " files"], - writablesln![Newline, "Done."], + &[Writable::Newline], ) } } diff --git a/src/main.rs b/src/main.rs index 9bd6c36..764d8cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -147,6 +147,10 @@ fn main() { let prompt = args.prompt.unwrap_or(Prompt::Error); + let mut renamed = 0_u32; // files that were successfully renamed + let mut skipped = 0_u32; // files that were skipped over without trying to rename + let mut failed = 0_u32; // files that fif failed to rename - e.g. files that are exclusively locked + for f in findings { if let Some(rename_to) = f.recommended_path() { let will_rename = { @@ -171,13 +175,16 @@ fn main() { }; if !will_rename { + skipped += 1; continue; } loop { + // until file is renamed successfully match std::fs::rename(&f.file, &rename_to) { Ok(_) => { info!("Renamed {:#?} -> {:#?}", f.file, rename_to); + renamed += 1; break; } Err(e) => { @@ -185,6 +192,7 @@ fn main() { // if the user passed --prompt never, continue to the next file // otherwise, prompt user to retry move, retrying until the rename succeeds or they respond "N" if prompt == Prompt::Never || !ask(&*format!("Error while renaming file: {:#?}. Try again?", e)) { + failed += 1; break; } } @@ -193,8 +201,17 @@ fn main() { } else { // no recommended name :c info!("No known extension for file {:#?} of type {}", f.file, f.mime); + skipped += 1; } } + + info!( + "Processed {} files: Renamed {}, skipped {}, failed to rename {}", + renamed + skipped + failed, + renamed, + skipped, + failed + ); } else { let mut buffered_stdout = BufWriter::new(stdout());