#1 2019-09-30 15:54

mosarket
Member
Registered: 2019-09-30
Posts: 2

I get incorrect creation date on PDF files?

Hello

I am trying to rename a bunch of PDF files by their creation date. All my files are in Evernote. So to rename them I need to download the PDFs from Evernote first. After doing this, when I try to rename the files using Insert>Insert Meta Tag>File_DateCreated it doesn't pull the correct date. It uses the date I saved the PDFs from Evernote to my desktop. Yet when I open the PDF and look at at the creation date it is not the date I saved the attachements from Evernote to my desktop, but the true date of creation.

I'm not sure why it won't pull the correct date. Any ideas?

Offline

#2 2019-09-30 18:12

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: I get incorrect creation date on PDF files?

mosarket wrote:

..., when I try to rename the files
using Insert>Insert Meta Tag>File_DateCreated
it doesn't pull the correct date.
...


Hi and welcome.

If you take a closer look at the meta tags, you  will see a list like
:File_DateCreated:
:ID3_Artist:
:HTML_Title:
:EXIF_Date:
:IPTC_Caption:
:Image_Width:
:Document_Author:
:Email_Subject:
:Outlook_DateSent:
:AVI_Duration:
:VersionInfo_Company: (*.exe)

so you can guess that the first token correspond to the file type:
-- basic File information like seen in WinExplorer,
-- ID3 tags from MP3 file,
-- Tags from Images who store metadata,
--  and so on,
but there is No :PDF_DateCreated:

For more information see
http://www.den4b.com/wiki/ReNamer:Meta_Tags
and from there
http://www.den4b.com/wiki/ReNamer:Scripts
which points to
» ReNamer    » PDF tags (pdfinfo.exe) (be sure to read that whole thread to get every updated information)
http://www.den4b.com/forum/viewtopic.php?id=349

den4b wrote:

The problem is that extracting tags from PDF is no easy task,
... there is possibility of using a 3-rd party executable tool to extract the tags from PDF,
and then with a help of PascalScript, use them within ReNamer.
...



Google for "Experts Exchange 6. Run the PDFinfo utility on the sample PDF file"
for to see an example output of PDF metadata.


HTH? big_smile


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

#3 2019-09-30 18:44

mosarket
Member
Registered: 2019-09-30
Posts: 2

Re: I get incorrect creation date on PDF files?

Thanks Stefan for the detailed reply.

That helps. I'm not proficient with this sort of thing (not a programmer/coder/etc, just a humble paper shuffler hoping to do things more efficiently), but I managed to follow the directions to the point where I've added a Pascal Script rule in Renamer. So now I have to change the TAG to extract the date of creation, but I'm not sure what phrase to use. I tried the following and it did not compile.

{ Extract PDF tags using Xpdf }

const
  EXE = 'pdfinfo.exe -enc UTF-8';
  TAG = 'DateCreated';

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(DateCreated);
  end;
end.

Offline

#4 2019-09-30 19:24

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: I get incorrect creation date on PDF files?

1.
>>>" it did not compile. "
So please post the error message here ( Ctrl+C // Ctrl+V)


2.
>>> "WideExtractFileExt(DateCreated)"
you can't extract the file extension from a var which contains a date.
Extract from FileName or FilePath:
WideExtractFileExt(FileName)


3.
As seen from the "Experts Exchange" example, the right tag you want would be "CreationDate", isn't it?
There is no 'DateCreated' in PDF meta tag?!


4.
Next that line "CreationDate" contains signs not allowed to use for an filename ( '/' and ':' ).
So you have to replace that signs by something better.
Also that extracted line still contains the word "CreationDate:" in front and have to be removed.
For PascalScript tools see http://www.den4b.com/wiki/ReNamer:Pasca … :Functions


- - -

To help you,
execute that pdfinfo.exe from a command line (cmd.exe)
and provide us the output of that tool (as plain text, not as screenshot),
especially the line with the wanted information.


EDIT
If have tested this now on my own, here are my explanations...
http://www.den4b.com/forum/viewtopic.ph … 088#p11088

Or see this code:

//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 ';

  //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+'"';
  if ExecConsoleApp(Command, Output) = 0 then
  begin
    Matches := SubMatchesRegEx(Output, TAG, False);
    if Length(Matches) = 6 then
      begin
        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.

/EDIT




 


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

Board footer

Powered by FluxBB