User:FrankM/gettime.pl

From OpenStreetMap Wiki
Jump to: navigation, search

This Perl script extracts the timestamp from WAV files created by the Windows software for Olympus voice recorders

use File::Format::RIFF;
foreach my $file (@ARGV)
{
   open( IN, $file ) or die "Could not open file: $!";
   my $riff1  = File::Format::RIFF->read( \*IN );
   close( IN );
   foreach $i (@{$riff1->{'data'}})
   {
       if($i->{'id'} eq 'cd  ')
       {
           my @x = unpack("C*",$i->{'data'});
           printf("$file\t%04d/%02d/%02d-%02d:%02d:%02d\n",
               ($x[0]+2000),$x[1],$x[2],$x[3],$x[4],$x[5]);
       }
   }
}