mirror of
https://github.com/SinTan1729/movie-rename.git
synced 2024-12-27 04:38:35 -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
15
src/main.rs
15
src/main.rs
|
@ -56,7 +56,19 @@ fn main() {
|
||||||
api_key: api_key,
|
api_key: api_key,
|
||||||
language: "en",
|
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 {
|
for filename in filenames {
|
||||||
|
if filename == "--dry-run".to_string() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let metadata = Metadata::from(filename.as_str()).unwrap();
|
let metadata = Metadata::from(filename.as_str()).unwrap();
|
||||||
let results = tmdb
|
let results = tmdb
|
||||||
.search()
|
.search()
|
||||||
|
@ -112,9 +124,12 @@ fn main() {
|
||||||
println!("{} already has correct name.", filename);
|
println!("{} already has correct name.", filename);
|
||||||
} else {
|
} else {
|
||||||
println!("{} -> {}", filename, new_name);
|
println!("{} -> {}", filename, new_name);
|
||||||
|
if dry_run == false {
|
||||||
|
println!("Doing the actual rename.");
|
||||||
fs::rename(filename, new_name).expect("Unable to rename file.");
|
fs::rename(filename, new_name).expect("Unable to rename file.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn display(movie: &MovieEntry) -> String {
|
fn display(movie: &MovieEntry) -> String {
|
||||||
|
|
Loading…
Reference in a new issue