@@ -54,7 +54,7 @@ fn main() -> ExitCode {
5454 input_dir. as_os_str( ) . to_string_lossy( )
5555 ) ;
5656
57- let photos = WalkDir :: new ( input_dir)
57+ let supported_files = WalkDir :: new ( input_dir)
5858 . into_iter ( )
5959 . filter_map ( |e| e. ok ( ) )
6060 . filter ( |e| e. file_type ( ) . is_file ( ) )
@@ -68,26 +68,36 @@ fn main() -> ExitCode {
6868 _ => false ,
6969 }
7070 } )
71+ . map ( |e| e. into_path ( ) )
72+ . collect :: < Vec < PathBuf > > ( ) ;
73+ let max_files = supported_files. len ( ) ;
74+
75+ let photos = supported_files
76+ . iter ( )
7177 . enumerate ( )
72- . filter_map ( |( idx, e) | {
73- let exif = match File :: open ( e. path ( ) ) {
78+ . filter_map ( |( idx, path) | {
79+ let idx = idx + 1 ;
80+ print ! ( "\r Processing file {} / {}" , idx, max_files) ;
81+ let exif = match File :: open ( path) {
7482 Ok ( file) => exif:: Reader :: new ( )
7583 . continue_on_error ( true )
7684 . read_from_container ( & mut BufReader :: new ( & file) )
7785 . or_else ( |err| {
7886 err. distill_partial_result ( |errors| {
79- eprintln ! ( "{}: {} warning(s)" , e . path( ) . display( ) , errors. len( ) ) ;
87+ eprintln ! ( "\n {}: {} warning(s)" , path. display( ) , errors. len( ) ) ;
8088 errors. iter ( ) . for_each ( |e| eprintln ! ( " {}" , e) ) ;
8189 } )
8290 } )
8391 . ok ( ) ?,
8492 _ => return None ,
8593 } ;
8694
87- let name = e. file_name ( ) . to_string_lossy ( ) . to_string ( ) ;
88- let path = e. path ( ) ;
95+ let name = path. file_name ( ) ?. to_string_lossy ( ) . to_string ( ) ;
8996 let latitude = get_coord ( & exif, Tag :: GPSLatitude , Tag :: GPSLatitudeRef , "N" ) ?;
9097 let longitude = get_coord ( & exif, Tag :: GPSLongitude , Tag :: GPSLongitudeRef , "E" ) ?;
98+ if latitude. abs ( ) < 0.001 && longitude. abs ( ) < 0.001 {
99+ return None ;
100+ }
91101 let make = get_string ( & exif, Tag :: Make ) . unwrap_or ( UNKNOWN . to_string ( ) ) ;
92102 let model = get_string ( & exif, Tag :: Model ) . unwrap_or ( UNKNOWN . to_string ( ) ) ;
93103 let date = get_datetime ( & exif, Tag :: DateTimeOriginal ) . unwrap_or ( UNKNOWN . to_string ( ) ) ;
@@ -105,10 +115,9 @@ fn main() -> ExitCode {
105115 date,
106116 } )
107117 } )
108- . filter ( |i| i. lat . abs ( ) > 0.001 && i. lon . abs ( ) > 0.001 )
109118 . collect :: < Vec < PhotoInfo > > ( ) ;
110119
111- println ! ( "Found {} photo coordinates" , photos. len( ) ) ;
120+ println ! ( "\n Found {} photo coordinates" , photos. len( ) ) ;
112121 if photos. is_empty ( ) {
113122 return ExitCode :: SUCCESS ;
114123 }
0 commit comments