mirror of
https://github.com/SinTan1729/movie-rename.git
synced 2024-12-26 12:18:37 -06:00
Fixed error for missing director's name
This commit is contained in:
parent
7fee309ff3
commit
fb407a9b9c
1 changed files with 9 additions and 3 deletions
12
src/main.rs
12
src/main.rs
|
@ -30,10 +30,16 @@ impl MovieEntry {
|
||||||
// Generate desired filename from movie entry
|
// Generate desired filename from movie entry
|
||||||
fn rename_format(&self, mut format: String) -> String {
|
fn rename_format(&self, mut format: String) -> String {
|
||||||
format = format.replace("{title}", self.title.as_str());
|
format = format.replace("{title}", self.title.as_str());
|
||||||
if self.year.as_str() != "n/a" {
|
if self.year.as_str() != "N/A" {
|
||||||
format = format.replace("{year}", self.year.as_str());
|
format = format.replace("{year}", self.year.as_str());
|
||||||
|
} else {
|
||||||
|
format = format.replace("{year}", "");
|
||||||
|
}
|
||||||
|
if self.director.as_str() != "N/A" {
|
||||||
|
format = format.replace("{director}", self.director.as_str());
|
||||||
|
} else {
|
||||||
|
format = format.replace("{director}", "");
|
||||||
}
|
}
|
||||||
format = format.replace("{director}", self.director.as_str());
|
|
||||||
format
|
format
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +175,7 @@ fn main() {
|
||||||
println!("{} -> {}", filename, new_name);
|
println!("{} -> {}", filename, new_name);
|
||||||
// Only do the rename of --dry-run isn't passed
|
// Only do the rename of --dry-run isn't passed
|
||||||
if dry_run == false {
|
if dry_run == false {
|
||||||
println!("Doing the actual rename.");
|
println!("Renaming...");
|
||||||
fs::rename(filename, new_name).expect("Unable to rename file.");
|
fs::rename(filename, new_name).expect("Unable to rename file.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue