mirror of
https://github.com/SinTan1729/movie-rename.git
synced 2024-12-25 19:58:36 -06:00
Added support for dry running
This commit is contained in:
parent
e529ab2100
commit
89135740a8
1 changed files with 16 additions and 1 deletions
17
src/main.rs
17
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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue