I have a few thousand jpg files and I have them named by the EXIF Date of the camera, using a tool called "ReNamer" (http://www.den4b.com/downloads.php?project=ReNamer
So my files are named in the format 'yyyymmddhhmmss'
and so on...
The problem is that my camera, the date was set one day LATER than the ACTUAL day, so in reality, the above should actually be:
20090520021518.jpg (i.e. May 20)
20090521072110.jpg (i.e. May 21)
and so on...
ReNamer is pretty slick and had a pre-existing pascal script called "Hours Span" which I tweaked to something like the code attached, and it worked beautifully. I did this to change the hours of the of the same files. Sadly it didn't have a built-in "Days Span" pascal script.
I was wondering if anyone here could help me out with a "Days Span" pascal script. Again, I've attached the code snippet of the "Hours Span" with this thread as a reference.
Also, I've attached ReNamer's help guide (pdf) if needed.
// This HoursSpan script reads dates from filenames in format: yyyymmddhhnnss.JPG
// then adds/subtracts N hours from the date and prints the new date in the
// format defined by DateOutputFormat variable. HoursSpan variable defines
// how many hours should be added/subtracted (use minus for subtraction).
HoursSpan = -1; // amount of hours to add or subtract!!
DateOutputFormat = 'yyyymmddhhnnss'; // output date format!!
HoursPerDay = 24; // do not change this!!
iYear, iMonth, iDay, iHour, iMin, iSec: Integer;
Date, Time, DateTime: TDateTime;
procedure AddHours(var ADateTime: TDateTime; const ANumberOfHours: Integer);
ADateTime := ((ADateTime * HoursPerDay) + ANumberOfHours) / HoursPerDay;
// extract date-time variables as integers
iYear := StrToIntDef(Copy(FileName, 1, 4), -1);
iMonth := StrToIntDef(Copy(FileName, 5, 2), -1);
iDay := StrToIntDef(Copy(FileName, 7, 2), -1);
iHour := StrToIntDef(Copy(FileName, 9, 2), -1);
iMin := StrToIntDef(Copy(FileName, 11, 2), -1);
iSec := StrToIntDef(Copy(FileName, 13, 2), -1);
// process only if all variables are correctly converted
if (iYear >= 0) and (iMonth >= 0) and (iDay >= 0) and
(iHour >= 0) and (iMin >= 0) and (iSec >= 0) then
// create a new date-time variable
Date := EncodeDate(iYear, iMonth, iDay);
Time := EncodeTime(iHour, iMin, iSec, 0);
DateTime := Date + Time;
// add hours (use minus for subtracting)
// concatenate the rest of the filename and the new date
FileName := Copy(FileName, 20, Length(FileName));
FileName := FormatDateTime(DateOutputFormat, DateTime) + FileName;
// something went wrong
else FileName := 'INVALID INPUT';