ReNamer:Scripts:Xpdf: Difference between revisions
Jump to navigation
Jump to search
(Updated script for ReNamer 5.70 and Xpdf 3.03) |
(→Code: Updated the tested versions) |
||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Script integrates [http://www. | {{Up|ReNamer:Scripts}} | ||
Script integrates [http://www.xpdfreader.com/about.html Xpdf] command line tool in order to extract PDF tags. | |||
References: | |||
* http://www.den4b.com/forum/viewtopic.php?id=349 | |||
== Requirements == | == Requirements == | ||
* [http://www. | * Download [http://www.xpdfreader.com/download.html Xpdf tools] and extract <code>pdfinfo.exe</code> into ReNamer's folder. | ||
== Code == | == Code == | ||
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. | 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.xpdfreader.com/support.html Xpdf] web site or <code>pdfinfo.exe</code> command line tool. | |||
* Tested with ReNamer 7.1 + Xpdf tools 4.01.01. | |||
< | <syntaxhighlight lang="pascal"> | ||
{ Extract PDF tags using Xpdf } | { Extract PDF tags using Xpdf } | ||
const | const | ||
EXE = 'pdfinfo.exe'; | EXE = 'pdfinfo.exe -enc UTF-8'; | ||
TAG = 'Title\s*\:\s*(.*?)[\r\n]'; | TAG = 'Title\s*\:\s*(.*?)[\r\n]'; | ||
var | var | ||
Command, Output: String; | Command, Output: String; | ||
Matches: | Matches: TWideStringArray; | ||
begin | begin | ||
Command := | Command := EXE+' "'+FilePath+'"'; | ||
if ExecConsoleApp(Command, Output) = 0 then | if ExecConsoleApp(Command, Output) = 0 then | ||
begin | begin | ||
Line 29: | Line 38: | ||
end; | end; | ||
end. | end. | ||
</ | </syntaxhighlight> |
Latest revision as of 21:52, 7 September 2019
Script integrates Xpdf command line tool in order to extract PDF tags.
References:
Requirements
- Download Xpdf tools and extract
pdfinfo.exe
into ReNamer's folder.
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 7.1 + Xpdf tools 4.01.01.
{ Extract PDF tags using Xpdf }
const
EXE = 'pdfinfo.exe -enc UTF-8';
TAG = 'Title\s*\:\s*(.*?)[\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.