#11 2007-05-02 19:03

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,199

Re: Date and Time from RAW images (CRW, CR2, RAW)

There might be a way, but it is very complicated.

ReNamer stores its settings in ReNamer.ini, in the same folder where the executable is. The date/time format is stored in that file, but gets updated only when you close the program. So the only possible way in which you could get that value, is by reading the ReNamer.ini from within PascalScript and extracting that value, but it will not be always up-to-date.

Offline

#12 2007-09-20 23:01

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,199

Re: Date and Time from RAW images (CRW, CR2, RAW)

Decided to update the script for the latest version of both tools.

As of today, 20-th September 2007, with ReNamer v5.05 and Exiv2 v0.15.

In addition to the script, I've put together a copy of ReNamer bundled with Exiv2 and the script.

This RAW Ready version is available for download from the downloads section for ReNamer.

{ Insert EXIF date from RAW images }

const
  EXIV = 'exiv2.exe';
  DTSTRING = 'Image timestamp';
  DTFORMAT = 'yyyy-mm-dd hh-nn-ss';

function TryExtractDate(const Output: WideString; var DateTime: TDateTime): Boolean;
var
  Lines: TStringsArray;
  I, Position: Integer;
  DateAndTime: String;
  Parts: TStringsArray;
  Date, Time: TDateTime;
  Year, Month, Day, Hour, Min, Sec: Integer;
begin
  Result := False;
  Lines := WideSplitString(Output, #13#10);
  for I := 0 to Length(Lines)-1 do
  begin
    Position := WideTextPos(DTSTRING, Lines[i]);
    if Position > 0 then
    begin
      Position := Position + WideLength(DTSTRING);
      DateAndTime := WideCopy(Lines[i], Position, WideLength(Lines[i]));
      DateAndTime := WideTrim(WideReplaceStr(DateAndTime, ':', ' '));
      Parts := WideSplitString(DateAndTime, ' ');
      if Length(Parts) = 6 then
      begin
        Year := StrToIntDef(Parts[0], -1);
        Month := StrToIntDef(Parts[1], -1);
        Day := StrToIntDef(Parts[2], -1);
        Hour := StrToIntDef(Parts[3], -1);
        Min := StrToIntDef(Parts[4], -1);
        Sec := StrToIntDef(Parts[5], -1);
        if (Year>0) and (Month>0) and (Day>0) and
           (Hour>=0) and (Min>=0) and (Sec>=0) then
        if TryEncodeDate(Year, Month, Day, Date) then
        if TryEncodeTime(Hour, Min, Sec, 0, Time) then
        begin
          DateTime := Date + Time;
          Result := True;
        end;
      end;
    end
  end;
end;

var
  Command, Output: string;
  DateTime: TDateTime;

begin
  Command := '"'+EXIV+'" "'+FilePath+'"';
  ExecConsoleApp(Command, Output);
  if TryExtractDate(Output, DateTime) then
    FileName := FormatDateTime(DTFORMAT, DateTime) +
      WideExtractFileExt(FileName);
end.

Offline

#13 2013-04-01 14:02

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,199

Re: Date and Time from RAW images (CRW, CR2, RAW)

For the latest version of this script please check the Wiki article: ReNamer:Scripts:Exiv2.

Alternatively, check the downloads section for the latest available RAW ready bundle.

As of today, 1 April 2013, the bundled version contains ReNamer v5.70 and Exiv2 v0.23.

Offline

Board footer

Powered by FluxBB