Restore PDF creation or modification date

Post Reply
pfischer
Member
Posts: 43
Joined: Tue May 14, 2013 4:57 pm

Restore PDF creation or modification date

Post by pfischer »

Hi all,

I know, that cross-posting is not a good way to spread a question, but unfortunately I haven't got any response to my post in the Switch Flows forum after 1,5 weeks. So I will try my luck in this PitStop Action List forum. Maybe my topic could be solved here. I think it is a general problem where to post, if a question concernes Switch as well as PitStop.

But here is problem: after downloading a PDF via Webservice from our file server, the modification date of the PDF file shown in the Windows Explorer changed to the moment of downloading. The original modification date is still available in the PDF document properties or in a PitStop preflight report.
At that moment I can't sort the files by date in the Windows Explorer.

Any idea how to restore the original date (creation / modification) with Switch or PitStop?

Thanks for your help,
Peter

[Windows 7, PitStop Pro 12, PitStop Server 12, Switch 12]
Media asset and production specialist
Group Communications / System Operations
Phoenix Contact GmbH & Co. KG
www.phoenixcontact.com
bens
Advanced member
Posts: 252
Joined: Thu Mar 03, 2011 10:13 am

Re: Restore PDF creation or modification date

Post by bens »

I know this is not what you want to hear, but perhaps you should forget the idea of coupling the file's creation to the PDF's internal creation date. They are fundamentally different concepts. When you download the file to your machine you are effectively creating a new file - which just happens to have the contents of the downloaded PDF. The file's creation date is purely a Windows file system affair, which has no real relation to the file's content.

If you really do want to continue down this path (and again, I urge you not to), then you will need quite a bit of scripting. Windows intentionally makes it hard to change a file's time stamps - and it has good reasons for doing so. The most obvious reason is that many programs will be very confused if you happen to do something inconsistent; for example a modification date that is earlier than the creation date, or a date in the future.

What I'm trying to say is: the OS (actually the file system) automatically handles all file time stamps, and it really doesn't want you to mess with them.

Furthermore, you shouldn't really trust the internal date in a PDF. I've seen many a file where the date was simply incorrect, or several conflicting dates were used.

And then there's the issue of time zones. You cannot know which time zone a PDF was created in, simply because that information is not available in the PDF. Nor is there any way to know whether the original producer and any application took the OS time zone information into account or not.

OK so if you read this far and you really, really, *really* want to do this, then you will first need to extract the date from the PDF. This can be done in Switch with the variables [Metadata.Date:Path="xmp:CreateDate"] and [Metadata.Date:Path="xmp:ModifyDate"]. Then use a Switch script or script expression to parse the PDF date into a JavaScript Date object. Finally, use an external application to change the file's time stamps. Microsoft Powershell can do this, see for example http://stackoverflow.com/questions/5825 ... -on-a-file and https://blogs.technet.microsoft.com/hey ... me-stamps/
pfischer
Member
Posts: 43
Joined: Tue May 14, 2013 4:57 pm

Re: Restore PDF creation or modification date

Post by pfischer »

Hi bens,

thank you for your detailed explanation. I think I can unterstand your reservations against this acting and I share them with you.

For us the situation is disadvantegous because of the following issues. Several print suppliers deliver us their print data after finishing the print jobs, so we can archive the PDFs for future usage. Unfortunately all PDFs loose their modification date if we download them from our transfer server. If we download a bigger amount of PDFs at the same time, all have the same modification date (the date of the download process) and it is not possible to sort them in file explorer.

But I think your arguments make sense to leave the PDFs untouched. I have two ideas to have a compromise:
1. to add the orginal date (internal PDF modification date) via a Switch variable to the filename
2. to use the orginal date and to create a folder structure to cluster the PDFs (e.g. by day/month/year) with a Switch variable

I will think about, if one of this ways would help us. Thank you so far.
Peter
Media asset and production specialist
Group Communications / System Operations
Phoenix Contact GmbH & Co. KG
www.phoenixcontact.com
bens
Advanced member
Posts: 252
Joined: Thu Mar 03, 2011 10:13 am

Re: Restore PDF creation or modification date

Post by bens »

Both those sound like good ideas, and certainly doable with Switch.

Good luck :-)

Ben
Post Reply