Difference between revisions of "ReNamer:Scripts:Xpdf"

From den4b Wiki
Jump to navigation Jump to search
(Navigation)
(Tested versions of ReNamer)
Line 7: Line 7:
  
 
== Requirements ==
 
== Requirements ==
* ReNamer 5.70
+
 
 
* [http://www.foolabs.com/xpdf/download.html pdfinfo.exe] 3.03 in ReNamer's folder
 
* [http://www.foolabs.com/xpdf/download.html pdfinfo.exe] 3.03 in ReNamer's folder
  
Line 13: Line 13:
  
 
Author: Denis Kozlov. Date: 2013-04-01. Modify the <code>TAG</code> constant to specify which tag you want to extract. For the list of available tags consult [http://www.foolabs.com/xpdf/ Xpdf] web site or <code>pdfinfo.exe</code> command line tool.
 
Author: Denis Kozlov. Date: 2013-04-01. Modify the <code>TAG</code> constant to specify which tag you want to extract. For the list of available tags consult [http://www.foolabs.com/xpdf/ Xpdf] web site or <code>pdfinfo.exe</code> command line tool.
 +
 +
* Tested with ReNamer 5.70.
  
 
<source>
 
<source>

Revision as of 15:40, 25 November 2015

Script integrates Xpdf command line tool in order to extract PDF tags.

References:

Requirements

Code

Author: Denis Kozlov. Date: 2013-04-01. Modify the TAG constant to specify which tag you want to extract. For the list of available tags consult Xpdf web site or pdfinfo.exe command line tool.

  • Tested with ReNamer 5.70.
{ Extract PDF tags using Xpdf }
 
const
  EXE = 'pdfinfo.exe';
  TAG = 'Title\s*\:\s*(.*?)[\r\n]';
 
var
  Command, Output: String;
  Matches: TStringsArray;  
 
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.