From 89135740a8eb309d7b9b3f1d007ed239cad46866 Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Thu, 8 Dec 2022 00:29:11 -0600 Subject: [PATCH] Added support for dry running --- src/main.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 5db588a..dc5b0b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,7 +56,19 @@ fn main() { api_key: api_key, language: "en", }; + + let mut dry_run = false; + + if filenames.contains(&"--dry-run".to_string()) { + println!("Doing a dry run."); + dry_run = true; + } + for filename in filenames { + if filename == "--dry-run".to_string() { + continue; + } + let metadata = Metadata::from(filename.as_str()).unwrap(); let results = tmdb .search() @@ -112,7 +124,10 @@ fn main() { println!("{} already has correct name.", filename); } else { println!("{} -> {}", filename, new_name); - fs::rename(filename, new_name).expect("Unable to rename file."); + if dry_run == false { + println!("Doing the actual rename."); + fs::rename(filename, new_name).expect("Unable to rename file."); + } } } }