Limbic~Region has asked for the wisdom of the Perl Monks concerning the following question:
All,
I am looking for a little help with a File::Find::Rule and Image::ExifTool script. My environment is Windows but I only have Perl available via Cygwin. I have a bunch of hard drives in this machine collected over the years so a manual search has proven to be untenable.
I am looking for a little help with a File::Find::Rule and Image::ExifTool script. My environment is Windows but I only have Perl available via Cygwin. I have a bunch of hard drives in this machine collected over the years so a manual search has proven to be untenable.
- Search all files with a .jpg or .jpeg extension (case insensitive)
- Once found, check to see when the photo was taken.
- If taken in 2015, give me the path to the file and the date the picture was taken
I haven't really coded in years so while this once seemed like a trivial task, I am having issues getting the expected results.
#!/usr/bin/perl use strict; use warnings; use File::Find::Rule; use Image::ExifTool qw(:Public); my $tool = Image::ExifTool->new(); for my $file (File::Find::Rule->file()->name( qr/\.(jpeg|jpg)$/i)->in( +'/')) { my $info = ImageInfo($file, 'DateTimeOriginal'); my $date = $info->{DateTimeOriginal}; next if ! $date || $date !~ /^2015/; print "$file\t$date\n"; }
When I tried it in my home directory as a test, it did exactly what I expected but when I changed '.' to '/' it started generating every file on the system (directories, text files, etc.) without the date.
Cheers - L~R
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Find Photos Taken During A Certain Time Range
by haukex (Archbishop) on Jul 30, 2020 at 19:18 UTC | |
Re: Find Photos Taken During A Certain Time Range
by Fletch (Bishop) on Jul 30, 2020 at 19:37 UTC | |
by flexvault (Monsignor) on Jan 08, 2021 at 21:24 UTC | |
Re: Find Photos Taken During A Certain Time Range
by bliako (Monsignor) on Jul 30, 2020 at 19:23 UTC |
Back to
Seekers of Perl Wisdom