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,20 +181,23 @@ 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() {
"gif" => { handle_gif( inode) } "doc" => { handle_document(inode) }
"jpg" => { handle_image(inode) } "docx" => { handle_document(inode) }
"jpeg" => { handle_image(inode) } "odt" => { handle_document(inode) }
"png" => { handle_image(inode) } "rtf" => { handle_document(inode) }
"iso" => { handle_iso( inode) } "gif" => { handle_gif( inode) }
"mp3" => { handle_mp3( inode) } "jpg" => { handle_image( inode) }
"pdf" => { handle_pdf( inode) } "jpeg" => { handle_image( inode) }
"avi" => { handle_video(inode) } "png" => { handle_image( inode) }
"m4v" => { handle_video(inode) } "iso" => { handle_iso( inode) }
"mkv" => { handle_video(inode) } "mp3" => { handle_mp3( inode) }
"mp4" => { handle_video(inode) } "pdf" => { handle_pdf( inode) }
// todo m4a, flac, etc? "avi" => { handle_video( inode) }
// todo pdf, other documents "m4v" => { handle_video( inode) }
_ => { /*println!("Here's where we would do nothing.");*/ } "mkv" => { handle_video( inode) }
"mp4" => { handle_video( inode) }
// todo other documents
_ => { println!("Not sure what to do with file: {:?}.", inode.path()); }
} }
} }
} }