Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Neat. Mine looked like this:
#!/usr/bin/env perl use strict; $|++; use Image::ExifTool qw(ImageInfo); use Time::Local; for my $file (@ARGV) { my $ii = ImageInfo($file, qw(DateTimeOriginal DateTime)) or warn("Skipping $file\n"), next; my ($created) = grep /\S/, @$ii{qw(DateTimeOriginal DateTime)}; next unless $created; warn "using $created for $file\n"; if ($created =~ s/([-+ ])(\d\d):(\d\d)$//) { my ($sign, $hour, $minute) = ($1, $2, $3); # warn "ignoring offset of $sign $hour:$minute\n"; } my @digits = $created =~ /(\d+)/g or next; if ($digits[0] < 1900) { warn "bad year $digits[0] for $file"; next; } $digits[0] -= 1900; $digits[1] -= 1; my $gmtime = timegm(reverse @digits); if ($gmtime > time or $gmtime < time - 86400*90) { warn "preposterous gmtime for $file: ", scalar gmtime $gmtime; # next; } utime($gmtime, $gmtime, $file) or warn "Cannot utime on $file: $!"; }

-- Randal L. Schwartz, Perl hacker

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.


In reply to Re: Change Image File Timestamp to Match EXIF Data by merlyn
in thread Change Image File Timestamp to Match EXIF Data by shoness

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-25 16:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found