#1 2024-03-07 10:05

Pawel
Member
Registered: 2023-06-06
Posts: 3

Converting the modification date to the exif date

Is there a way to change the file modification date to the date stored in EXIF?

Offline

#2 2024-03-23 15:24

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

Re: Converting the modification date to the exif date

Pawel wrote:

Is there a way to change the file modification date to the date stored in EXIF?

Can you confirm if you want the exif date to be applied to the file modification date, or the other way around?

There are ways to do both, but the tools will differ based on your answer.

Offline

#3 2024-03-23 15:26

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

Re: Converting the modification date to the exif date

A script included below for the Pascal Script rule will read the exif date and apply it to the file modification date.

Be aware: The script will be executed on every Preview operation, as opposed to a Rename operation. This is just how renaming rules work. All successfully processed files will have their names prefixed with a plus sign, which may be useful for validation, but otherwise you can comment out this effect in the script.

var
  ExifDateStr: WideString;
  ExifDate: TDateTime;

const
  TempDateFormat = 'yyyy-mm-dd hh:nn:ss';

begin
  ExifDateStr := CalculateMetaTagFormat(FilePath, 'Exif_Date', TempDateFormat);
  if Length(ExifDateStr) > 0 then
  begin
    ExifDate := ScanDateTime(TempDateFormat, ExifDateStr);
    if SetFileTimeModified(FilePath, ExifDate) then
      FileName := '+' + FileName
    else
      Error('Failed to set the modified date on file: ' + FilePath);
  end;
end.

Alternatively, it should be possible to achieve the same effect with these capable command line tools: ExifTool and Exiv2. There should be some good examples online.

Offline

#4 2024-04-04 08:54

Pawel
Member
Registered: 2023-06-06
Posts: 3

Re: Converting the modification date to the exif date

This works very well, thank you

Offline

Board footer

Powered by FluxBB