diff options
author | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-06-27 13:21:36 -0400 |
---|---|---|
committer | Jeff Zhao <jeff.no.zhao@gmail.com> | 2022-06-27 13:28:32 -0400 |
commit | 0c809c7b17247ecab80b8571ac15414c2a019dce (patch) | |
tree | 2f16844ca78338acc3e52dbee9718d3272e24149 /src/commands | |
parent | 19d59e9290493b8b645abcbe0e4e036b08b750e3 (diff) |
fix bulk_rename logic error
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/bulk_rename.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/commands/bulk_rename.rs b/src/commands/bulk_rename.rs index bca4c9f..87d69fe 100644 --- a/src/commands/bulk_rename.rs +++ b/src/commands/bulk_rename.rs @@ -100,19 +100,21 @@ pub fn _bulk_rename(context: &mut AppContext) -> JoshutoResult { let mut user_input = String::with_capacity(4); std::io::stdin().read_line(&mut user_input)?; - user_input = user_input.to_lowercase(); - - let user_input_trimmed = user_input.trim(); - if user_input_trimmed != "n" || user_input_trimmed != "no" { - for (p, q) in entries.iter().zip(paths_renamed.iter()) { - let mut handle = process::Command::new("mv") - .arg("-iv") - .arg("--") - .arg(p.file_name()) - .arg(q) - .spawn()?; - handle.wait()?; + + let user_input_fmt = user_input.trim().to_lowercase(); + match user_input_fmt.as_str() { + "y" | "yes" => { + for (p, q) in entries.iter().zip(paths_renamed.iter()) { + let mut handle = process::Command::new("mv") + .arg("-iv") + .arg("--") + .arg(p.file_name()) + .arg(q) + .spawn()?; + handle.wait()?; + } } + _ => {}, } wait_for_enter()?; |