1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
use crate::check_file::{check_file, CheckStatus}; use crate::extract_metadata::PhotoMetadata; use crate::fs_operations::{create_dirs, move_file}; use crate::scan_dir::scan_dir; use std::path::Path; pub fn process_dir(root_path: &Path) { let files = scan_dir(&root_path); println!("Scanning completed with {} files to process", files.len()); for file_path in files { process_file(&file_path, &root_path); } } fn process_file(file_path: &Path, root_path: &Path) { let metadata = PhotoMetadata::from_file(&file_path); if metadata.is_err() { return; }; let metadata = metadata.unwrap(); let status = check_file(&file_path, &metadata, &root_path); if let CheckStatus::Wrong(correct_path) = status { create_dirs(&correct_path); move_file(&file_path.to_path_buf(), &correct_path); println!("Correctly processed file: {}", &file_path.display()); } }