Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- # usage: ./date-correct.pl +1*60*60 *.jpg
- # 1. Argument: zu addierender Zeitoffset in Sekunden, etwa
- # 42 = 42 sekunden draufaddieren auf alle dateien-mtimes
- # -12 = 12 Sekunden abziehen " " "
- # -60*60 = 1h abziehen
- # etc.
- #
- # Beispiele:
- # ../Date-corrector.pl -60*60 001* 002* 003* 004*
- # -> Bilder mit "001" bis "004" um 1h zurueck korrigieren
- # find -newer 004.* -print0 | sort -z | xargs -0 -n1 ../Date-corrector.pl -60*60
- # -> alle Bilder ab "004" nehmen, sortieren und einzeln um 1h zurueck korrigieren
- use strict;
- use File::stat;
- use POSIX qw(strftime);
- sub touchf { return strftime "%y%m%d%H%M.%S", localtime($_[0]); }
- my $ds = shift @ARGV;
- my $d = eval $ds; die "Delta-Zeitargument ($ds) falsch: $@" if $@;
- #print "Making $d seconds offset\n";
- for(@ARGV) {
- unless(-e) { die "File $_ does not exist!\n"; }
- my $otime = stat($_)->mtime;
- my $ntime = $otime + $d;
- my $o = touchf($otime); my $n = touchf($ntime);
- #print "$_: $otime => $ntime\n";
- #print "$_: $o => $n\n";
- my $cmd = "touch -t$n -m '$_'";
- print "$d sec offset: $cmd\n";
- `$cmd`;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement