App-Utils

 view release on metacpan or  search on metacpan

bin/date-tag-file  view on Meta::CPAN

#!/usr/bin/perl
# date-tag-file - pre-tag filename with timestamp of last modification
# 2020 Vlado Keselj http://web.cs.dal.ca/~vlado
# last update: 2020-05-26
$|=1;
for my $f (@ARGV) {
  my @s = stat($f); die unless @s;
  my $mtime = $s[9];
  my ($S,$M,$H,$d,$m,$y,$wd,$yd,$isdst) = localtime($mtime);
  $m+=1; $y+=1900;
  my $tag=sprintf("%4d-%02d-%02d", $y, $m, $d);
  my $nf = "$tag-$f"; die if -e $nf;
  print "$f -> $nf\n"; rename($f, $nf);
}

__END__ # Documentation



( run in 1.330 second using v1.01-cache-2.11-cpan-49f99fa48dc )