You are not logged in.
Further tests, this time with exiftool.exe
https://sno.phy.queensu.ca/~phil/exiftool/
(((output here in German date format, with leading zero on date less then 10, month name as number)))
D:\rive\Temp>exiftool.exe "TEST.pdf"
ExifTool Version Number : 9.69
File Name : TEST.pdf
Directory : .
File Size : 175 kB
File Modification Date/Time : 2011:02:09 12:49:14+01:00
File Access Date/Time : 2019:10:06 20:41:30+02:00
File Creation Date/Time : 2019:10:06 20:41:30+02:00
File Permissions : rw-rw-rw-
File Type : PDF
MIME Type : application/pdf
PDF Version : 1.4
Linearized : No
Page Count : 14
Modify Date : 2011:02:09 12:49:02+01:00
Create Date : 2011:02:09 12:49:02+01:00
Title : ExifTool by Phil Harvey
Author : name removed
Creator : Drucken
D:\rive\Temp>
exiftool.exe -TAG
Extract information for the specified tag (eg. -CreateDate).
Multiple tags may be specified in a single command.
A tag name may include leading group names separated by colons (eg. -EXIF:CreateDate,
D:\rive\Temp>exiftool.exe -CreateDate "TEST.pdf"
Create Date : 2011:02:09 12:49:02+01:00
D:\rive\Temp>
exiftool.exe -d FMT (-dateFormat) Set format for date/time values
D:\rive\Temp>exiftool.exe -d "%Y-%m-%d" -CreateDate "TEST.pdf"
Create Date : 2011-02-09
D:\rive\Temp>exiftool.exe -d "%Y-%m-%d %H%M%S" -CreateDate "TEST.pdf"
Create Date : 2011-02-09 124902
D:\rive\Temp>exiftool.exe -d "%d.%m.%y_%H%M" -CreateDate "TEST.pdf"
Create Date : 09.02.11_1249
D:\rive\Temp>
http://www.den4b.com/forum/viewtopic.ph … 092#p11092
Working code to get the CreationDate (no matter if German or English format):
by using exiftool.exe -d "%Y-%m-%d %H%M%S" -CreateDate "TEST.pdf"
//Working code to get the CreationDate (no matter if German or English format):
//Author: Denis Kozlov. Date: 2013-04-01. Stefan 2019-10-07
const
//EXE = 'exiftool.exe -d "%Y-%m-%d %H%M%S" -CreateDate ';
//https://sno.phy.queensu.ca/~phil/exiftool/
//EXAMPLE OUTPUT: Create Date : 2012-09-18 084825
EXE = 'exiftool.exe -d "Created %d.%m.%Y %H,%M" -CreateDate ';
//EXAMPLE OUTPUT: Create Date : Created 07.10.2012 22,39
//Find a line in the output, starting with "CreationDate".
TAG = 'Create Date\s+:\s+(.+)';
// Matches are count from the left: (0)
// Use that parts to compose the wanted NewName: Matches[0]
var
Command, Output: String;
Matches: TWideStringArray;
begin
Command := EXE+' "'+FilePath+'"';
//showmessage('Command: ' + Command);
if ExecConsoleApp(Command, Output) = 0 then
begin
Output:= trim(Output);
//showmessage('Output: __'+Output+'__');
Matches := SubMatchesRegEx(Output, TAG, False);
//showmessage('Matches: '+IntToStr(Length(Matches)));
if Length(Matches) = 1 then
begin
//showmessage('Matches: '+ Matches[0]);
// Compose wanted new name:
//FileName := Matches[0] + '_' + FileName;
FileName := WideExtractBaseName(FileName)+' (' + Matches[0] + ')'+WideExtractFileExt(FileName);
end
else
FileName := '__NOTHING_FOUND___'+FileName;
end
end.
### ### ###
Instead of Xpdf-pdfinfo.exe
(((output here in German date format, missing leading zero on date less then 10, month name as name/word.
Needs additional treatment for an useful output)))
D:\rive\Temp>pdfinfo.exe "TEST.pdf"
Title: TEST
Author: name removed
Creator: Drucken
CreationDate: Wed Feb 9 12:49:02 2011
ModDate: Wed Feb 9 12:49:02 2011
Tagged: no
Form: none
Pages: 14
Encrypted: no
Page size: 595.276 x 841.89 pts (A4) (rotated 0 degrees)
File size: 179702 bytes
Optimized: no
PDF version: 1.4
Tip from den4b "-rawdates", that will simplify the scripts above.
pdfinfo.exe -rawdates
(((output here in German date format, with leading zero on date less then 10, month name as number)))
D:\rive\Temp>pdfinfo.exe -rawdates "TEST.pdf"
Title: TEST
Author: name removed
Creator: Drucken
CreationDate: D:20110209124902+01'00'
ModDate: D:20110209124902+01'00'
Tagged: no
Form: none
Pages: 14
Encrypted: no
Page size: 595.276 x 841.89 pts (A4) (rotated 0 degrees)
File size: 179702 bytes
Optimized: no
PDF version: 1.4
D:\rive\Temp>
# # #
Working code to get the CreationDate (no matter if German or English format):
by using pdfinfo.exe -rawdates "TEST.pdf"
//Working code to get the CreationDate (no matter if German or English format):
//Author: Denis Kozlov. Date: 2013-04-01. Stefan 2019-10-07
const
EXE = 'pdfinfo.exe -enc UTF-8 -rawdates ';
//http://www.xpdfreader.com/
//Find a line in the output, starting with "CreationDate".
//EXAMPLE OUTPUT: CreationDate: D:20121007223943+01'00'
//EXAMPLE OUTPUT: CreationDate: D:2012 10 07 22 39 43+01'00'
TAG = 'CreationDate:\s+\w:(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d).+';
// Matches are count from the left: (0) (1) (2) (3) (4) (5)
// Use that parts to compose the wanted NewName: Matches[0] Matches[1] Matches[2]...
var
Command, Output: String;
Y,M,D,H,min,s,Delim:WideString;
Matches: TWideStringArray;
begin
Command := EXE+' "'+FilePath+'"';
//showmessage('Command: ' + Command);
//showmessage('Output: '+Output);
if ExecConsoleApp(Command, Output) = 0 then
begin
Matches := SubMatchesRegEx(Output, TAG, False);
//showmessage('Matches: '+IntToStr(Length(Matches)));
if Length(Matches) = 6 then
begin
//showmessage('Matches: '+ Matches[0]+'-'+Matches[1]+'-'+Matches[2]);
Y:=Matches[0];
M:=Matches[1];
D:=Matches[2];
H:=Matches[3];
min:=Matches[4];
s:=Matches[5];
Delim:='-';
// Compose wanted new name:
//FileName := Y+Delim+M+Delim+D+'_'+H+min+s+'_' + FileName;
//FileName := WideExtractBaseName(FileName)+' ('+Y+Delim+M+Delim+D+')'+WideExtractFileExt(FileName);
FileName := WideExtractBaseName(FileName)+' ('+D+'.'+M+'.'+Y+')'+WideExtractFileExt(FileName);
end
end
else
FileName := '__NOTHING_FOUND___'+FileName;
end.
So we can use one tool for both EXIF and PDF? ... more test needed...
# # #
More tested:
To insert Date Taken of an Image/Picture,
you can use the [Insert Meta Tag]-button
to insert meta data /TAGs from files, like ":EXIF_Date:".
Example:
1) Insert: Insert "_" as Prefix (skip extension)
2) Insert: Insert ":EXIF_Date:" as Prefix (skip extension)
Example output: 2006-07-07 20-12-17_OldName.JPG
Use further rules to modify that output to an format you want to use for your NewName.
Also you can utilize command line tools like exiv2.exe or exiftool.exe
together with an PascalScript to perform all need modification in one single rule.
Based on Script by Author: Denis Kozlov. Date: 2013-04-01. ( http://www.den4b.com/wiki/ReNamer:Scripts:Exiv2 )
exiv2.exe
https://www.exiv2.org/download.html
const
EXE = 'exiv2.exe';
//https://www.exiv2.org/download.html
//EXEMPLE COMMANDLINE OUTPUT: Image timestamp : 2006:07:07 20:12:17
TAG = 'Image timestamp\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
begin
//showmessage(Matches[0]); // 2006:07:07 20:12:17
Matches[0] := WideReplaceStr(Matches[0] ,':','-');
Matches[1] := WideReplaceStr(Matches[1] ,':','');
// Compose wanted new name:
//FileName := Matches[0] +'_'+Matches[1]+ WideExtractFileExt(FileName);
FileName := WideExtractBaseName(FileName)+'_('+Matches[0]+'_'+Matches[1]+')'+WideExtractFileExt(FileName);
end
else
FileName := '__NOTHING_FOUND__' + FileName;
end;
end.
Here with more comments for self learning:
exiftool.exe
https://sno.phy.queensu.ca/~phil/exiftool/
const
EXE = 'exiftool.exe';
//https://sno.phy.queensu.ca/~phil/exiftool/
//EXEMPLE COMMANDLINEOUTPUT: Create Date : 2006:07:07 20:12:17
//RegularExpression for the SubMatchesRegEx() command below:
TAG = 'Create Date\s*:\s*(.*?) (.*?)[\r\n]';
var
Command, Output: String;
Matches: TWideStringArray;
begin
//Build the command line command and store in var "Command":
Command := EXE+' "'+FilePath+'"';
//Execute the Command and gather result in var "Output":
if ExecConsoleApp(Command, Output) = 0 then
begin
//Execute SubMatchesRegEx() on var "Output"
// with expression in var "TAG"
// to get the wanted line from "Output":
Matches := SubMatchesRegEx(Output, TAG, False);
//If something is found "Matches == 1 or more":
if Length(Matches) > 0 then
begin
//showmessage(Matches[0]); //Shows for example "2006:07:07 20:12:17"
Matches[0] := WideReplaceStr(Matches[0] ,':','-');
Matches[1] := WideReplaceStr(Matches[1] ,':','');
// Compose wanted new name:
//FileName := Matches[0] +'_'+Matches[1]+ WideExtractFileExt(FileName);
FileName := WideExtractBaseName(FileName)+'_('+Matches[0]+'_'+Matches[1]+')'+WideExtractFileExt(FileName);
end
else
FileName := '__NOTHING_FOUND__' + FileName;
end;
end.
Last edited by Stefan (2019-10-07 11:19)
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline