Difference between revisions of "ReNamer:Scripts:ExifTool"

From den4b Wiki
Jump to: navigation, search
(Created page with "{{Up|ReNamer:Scripts}} This script integrates [https://exiftool.org/ ExifTool] command tool in order to extract EXIF/IPTC/XMP tags from many types of images. CRW, CR2, RAW, H...")
 
(Script: Date corrected.)
 
Line 13: Line 13:
 
== Script ==
 
== Script ==
  
Author: Denis Kozlov. Date: 2019-01-06.
+
Author: Denis Kozlov. Date: 2020-01-06.
  
 
Replace the filename with the "Date/Time Original" meta tag.
 
Replace the filename with the "Date/Time Original" meta tag.

Latest revision as of 16:01, 6 January 2020

This script integrates ExifTool command tool in order to extract EXIF/IPTC/XMP tags from many types of images. CRW, CR2, RAW, HEIF/HEVC images are also supported.

Requirements

  • exiftool.exe in ReNamer's folder.

Download and extract the ExifTool package into ReNamer's folder.

Note that the ExifTool for Windows package contains a file named exiftool(-k).exe, which must be renamed to exiftool.exe before using in ReNamer. Otherwise, the command line tool interprets the (-k) text as a trigger to wait for the user to press the ENTER key at the end of the output, which ReNamer won't be able to do and the application will just freeze.

Script

Author: Denis Kozlov. Date: 2020-01-06.

Replace the filename with the "Date/Time Original" meta tag.

The meta tag output is used "as is" and it often contains invalid filename characters, so you may need to use additional rules to clean up the filename afterwards.

You can check the full list of available meta tags by running exiftool.exe <file> comamnd and then you can modify the TAG constant to work with any of the listed tags.

  • Tested with ReNamer 7.1 and ExifTool 11.81.
const
  EXE = 'exiftool.exe -t';
  TAG = 'Date/Time Original' + '\t(.*?)[\r\n]';

var
  Command, Output: String;
  Matches: TWideStringArray;

begin
  Command := EXE + ' "' + FilePath + '"';
  if ExecConsoleApp(Command, Output) = 0 then
  begin
    Matches := SubMatchesRegEx(Output, TAG, False);
    if Length(Matches) > 0 then
      FileName := Matches[0] + WideExtractFileExt(FileName);
  end;
end.