I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2007-12-20 07:17:49-08 by bv
How to create a composite date that is shifted by 2 months earlier

Hi Phil,

I am finding out that my AVI files have a DateTimeOriginal stamp of 2 months later that it was taken. Since you do not support writting to RIFF (whatever that means) at this time, I need to figure out how to return a date that has been correct (shifted by -2 months.

This is what I have tied but have been unsuccessful. It always returns only the YEAR.

DateTime2 => { Require => 'DateTimeOriginal', ValueConv => '$val', }, DateTimeAVI => { Require => 'DateTimeOriginal', ValueConv => '$val - "0:2:0 0:0:0"', }, exiftool -datetimeavi -datetime2 -alldates *.* ======== MVI_0149.AVI Date Time AVI : 2005 Date Time 2 : 2005:07:19 21:34:00 Date/Time Original : 2005:07:19 21:34:00 ======== MVI_0149.THM Date Time AVI : 2005 Date Time 2 : 2005:05:19 21:34:00 Date/Time Original : 2005:05:19 21:34:00 Create Date : 2005:05:19 21:34:00 Modify Date : 2005:05:19 21:34:00 2 image files read

To help rename and copy the files I have created this dos batch file. I need the corrected date becuase the files will end up with the wrong filename and wrong folders.

Here is the batch file and results:

@echo on Rem Fix_AVI_Files will perform the following Rem Make archive and new working folders/directories Rem copies original file to new filename format in the working folder Rem moves the original file to the archive folder set Ext=-ext avi *.avi set Ext2=-ext thm *.thm set targetDir=Q:\Photos set origDir=F:\Photos\Original set OutFile=Rename-avi.cmd Rem Set Date Shift as the AVI files have a DatTimeOriginal of + 2 months from Thm and still photos Rem Do NOT KNOW HOW TO USE the correct syntax is it is possible in a p- "FORMAT STR" Rem Other thought is to use a Composite TAG but have not gotten syntax correct set dsft=-'0:2:0 0:0:0' Echo @Echo off >%OutFile% echo Rem Build MakeDir Statements to make sure directory exists >>%OutFile% exiftool -q -S -s -d "%targetDir%\%%Y_%%m_%%d" -p "mkdir $DateTimeOriginal%" %Ext2% >>%OutFile% exiftool -q -S -s -d "%origDir%\%%Y_%%m_%%d" -p "mkdir $DateTimeOriginal" %Ext2% >>%OutFile% Echo Rem Build copy Statements for renamed files >>%OutFile% exiftool -q -S -s -d "%targetDir%\%%Y_%%m_%%d\%%Y-%%m%%d-%%H%%M%%S_" -p "copy $filename $DateTimeOr +iginal${filename}" %Ext% >>%OutFile% exiftool -q -S -s -d "%targetDir%\%%Y_%%m_%%d\%%Y-%%m%%d-%%H%%M%%S_" -p "copy $filename $DateTimeOr +iginal${filename}" %Ext2% >>%OutFile% rem exiftool -q -S -s -d "%origDir%\%%Y_%%m_%%d\%%Y-%%m%%d-%%H%%M%%S_" -p "copy $filename $DateTime +Original${filename}" %Ext% >>%OutFile% Echo Rem Build move Statements for Original files >>%OutFile% exiftool -q -S -s -d "%origDir%\%%Y_%%m_%%d" -p "move $filename $DateTimeOriginal" %Ext% >>%OutFile +% exiftool -q -S -s -d "%origDir%\%%Y_%%m_%%d" -p "move $filename $DateTimeOriginal" %Ext2% >>%OutFil +e% @Echo off Rem Rename-Avi.cmd file created by Fix_Avi_Files.cmd & Exiftool 7.06 above Rem Build MakeDir Statements to make sure directory exists mkdir F:\Photos\Original\2005_07_19 mkdir F:\Photos\Original\2005_05_19 Rem Build copy Statements for renamed files copy MVI_0149.AVI Q:\Photos\2005_07_19\2005-0719-213400_MVI_0149.AVI copy MVI_0149.THM Q:\Photos\2005_05_19\2005-0519-213400_MVI_0149.THM Rem Build move Statements for Original files move MVI_0149.AVI F:\Photos\Original\2005_07_19 move MVI_0149.THM F:\Photos\Original\2005_05_19
Direct Responses: 6734 | Write a response
Posted on 2007-12-20 12:29:32-08 by exiftool in response to 6732
Re: How to create a composite date that is shifted by 2 months earlier
Shifting date/time values is difficult because Perl (or any other language) doesn't provide built-in support for doing this. But you can take advantage of an ExifTool function to do this. The following user-defined tag will shift the date/time back by 2 months:

%Image::ExifTool::UserDefined = ( 'Image::ExifTool::Composite' => { ShiftedDateTime => { Require => 'DateTimeOriginal', ValueConv => q{ require 'Image/ExifTool/Shift.pl'; Image::ExifTool::ShiftTime($val, '0:2:0 0:0:0', -1); return $val; }, PrintConv => '$self->ConvertDateTime($val)', }, }, );
Direct Responses: Write a response