handle some documents
This commit is contained in:
parent
e6b9b927f4
commit
c311f3c2cb
27
src/main.rs
27
src/main.rs
|
@ -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() {
|
||||||
|
"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) }
|
||||||
"png" => { handle_image(inode) }
|
"png" => { handle_image( inode) }
|
||||||
"iso" => { handle_iso( inode) }
|
"iso" => { handle_iso( inode) }
|
||||||
"mp3" => { handle_mp3( inode) }
|
"mp3" => { handle_mp3( inode) }
|
||||||
"pdf" => { handle_pdf( inode) }
|
"pdf" => { handle_pdf( inode) }
|
||||||
"avi" => { handle_video(inode) }
|
"avi" => { handle_video( inode) }
|
||||||
"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.");*/ }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue