handle some documents

This commit is contained in:
Max Bradbury 2023-05-04 19:35:19 +01:00
parent e6b9b927f4
commit c311f3c2cb
1 changed files with 21 additions and 14 deletions

View File

@ -61,6 +61,10 @@ fn yes() -> bool {
answer.to_lowercase().starts_with("y") answer.to_lowercase().starts_with("y")
} }
fn handle_document(file: DirEntry) {
move_file(file.path(), documents_dir());
}
fn handle_image(file: DirEntry) { fn handle_image(file: DirEntry) {
move_file(file.path(), pictures_dir()); move_file(file.path(), pictures_dir());
} }
@ -177,6 +181,10 @@ fn handle_dir(path: PathBuf) {
if let Some(extension) = inode.path().extension().unwrap_or("none".as_ref()).to_str() { if let Some(extension) = inode.path().extension().unwrap_or("none".as_ref()).to_str() {
match extension.to_string().to_lowercase().as_ref() { match extension.to_string().to_lowercase().as_ref() {
"doc" => { handle_document(inode) }
"docx" => { handle_document(inode) }
"odt" => { handle_document(inode) }
"rtf" => { handle_document(inode) }
"gif" => { handle_gif( inode) } "gif" => { handle_gif( inode) }
"jpg" => { handle_image( inode) } "jpg" => { handle_image( inode) }
"jpeg" => { handle_image( inode) } "jpeg" => { handle_image( inode) }
@ -188,9 +196,8 @@ fn handle_dir(path: PathBuf) {
"m4v" => { handle_video( inode) } "m4v" => { handle_video( inode) }
"mkv" => { handle_video( inode) } "mkv" => { handle_video( inode) }
"mp4" => { handle_video( inode) } "mp4" => { handle_video( inode) }
// todo m4a, flac, etc? // todo other documents
// todo pdf, other documents _ => { println!("Not sure what to do with file: {:?}.", inode.path()); }
_ => { /*println!("Here's where we would do nothing.");*/ }
} }
} }
} }