forked from andrewgremlich/media_organizer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
180919d
commit 0d17eed
Showing
12 changed files
with
84 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ photos/ | |
.DS_Store | ||
test-photos/ | ||
test-lib/ | ||
photo_organizer | ||
*_organizer | ||
media/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "media_organizer" | ||
version = "0.1.1" | ||
version = "0.2.0" | ||
authors = ["Andrew Gremlich <[email protected]>"] | ||
edition = "2018" | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
cp target/release/photo_organizer . | ||
cp target/release/media_organizer . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
extern crate glob; | ||
extern crate mkdirp; | ||
|
||
mod media_info; | ||
mod utils; | ||
|
||
use self::glob::glob; | ||
use media_info::date_data::{read_photo_creation_date, read_video_creation_date}; | ||
use mkdirp::mkdirp; | ||
use utils::{get_white_list_file_types, is_photo, is_video, make_dir_string, move_image}; | ||
|
||
fn make_photo_dir_str(dir_str: &str) -> String { | ||
let date_of_photo: String = read_photo_creation_date(dir_str); | ||
let photo_dir_str: String = make_dir_string(date_of_photo.split_whitespace().next()); | ||
return photo_dir_str; | ||
} | ||
|
||
fn make_video_dir_str(dir_str: &str) -> String { | ||
let date_of_video: String = read_video_creation_date(dir_str); | ||
let video_dir_str: String = make_dir_string(date_of_video.split("T").next()); | ||
return video_dir_str; | ||
} | ||
|
||
fn handle_path(path: &str) { | ||
let path_str: &str = path; | ||
let mut date_data: String = String::new(); | ||
|
||
if is_photo(path_str) { | ||
let photo_dir_str: String = make_photo_dir_str(path_str); | ||
date_data.push_str(&photo_dir_str); | ||
} | ||
if is_video(path_str) { | ||
let video_dir_str: String = make_video_dir_str(path_str); | ||
date_data.push_str(&video_dir_str); | ||
} | ||
|
||
mkdirp(&date_data).unwrap(); | ||
move_image(path_str, &date_data); | ||
} | ||
|
||
pub fn sort_file(file_path: &str) { | ||
handle_path(file_path); | ||
} | ||
|
||
pub fn sort_dir(dir_str: &str) { | ||
let white_list_file_types: Vec<&str> = get_white_list_file_types(); | ||
|
||
for file_type in &white_list_file_types { | ||
let mut glob_path: String = String::new(); | ||
|
||
glob_path.push_str(dir_str); | ||
glob_path.push_str("/*."); | ||
glob_path.push_str(file_type); | ||
|
||
for entry in glob(&glob_path).expect("Failed to read glob pattern") { | ||
match entry { | ||
Ok(path) => { | ||
handle_path(path.to_str().unwrap()); | ||
} | ||
Err(e) => println!("{:?}", e), | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.