pne: A picture of a plush toy, halfway between a duck and a platypus, with a green body and a yellow bill and feet. (Default)
[personal profile] pne

I generally like to have my file timestamps represent the real date of last modification, rather than the time at which I acquired the file.

To that end, for example, I generally try to download files using a method that preserves the file’s timestamp (such as using GetRight or curl rather than my browser).

However, sometimes I do use the browser, or I get the file from a source which had not preserved the file’s timestamp itself.

With PDF files, though, I find that most of them have a modification timestamp in the file’s metadata itself (and those that don’t often have at least a creation timestamp). So I occasionally update file timestamps based on that timestamp saved inside the file.

I used to do that manually, by looking at the “PDF” tab of the file’s properties and then modifying the file’s timestamp in my file manager.

But then I found that I could use Phil Harvey’s exiftool to do so.

Exiftool was designed to work with EXIF metadata in images, as the name suggests, but it can read (and sometimes write) metadata from other file formats as well, such as PDF, MP3, and others.

So I found I could use it to copy the metadata modification time to the filesystem modification time, with an invocation something like this:

perl -S exiftool "-FileModifyDate<ModifyDate" *.pdf

(Depending on how you installed it, the perl -S exiftool bit might be merely exiftool.)

The operative bit is the "-FileModifyDate<ModifyDate" bit (in double quotes due to the presence of <, which would otherwise have a special meaning): it copies the “modify date” metadata field to the file’s modification date. (If the PDF file has no modification date but does have a creation date, then use CreateDate instead of ModifyDate.)

And presto! All PDF files in the directory have “proper” modification dates.

Date: Sunday, 9 December 2012 17:47 (UTC)
kake: The word "kake" written in white fixed-font on a black background. (Default)
From: [personal profile] kake
Thank you for the recommendation of exiftool! I'd been wanting a command-line thing to look at EXIF data.

Date: Monday, 10 December 2012 09:03 (UTC)
schnurble: (Default)
From: [personal profile] schnurble
Exiftool is cool! I use it mainly for setting the modification timestamps of pictures to the time the pictures were taken. Or when I have pictures from several sources about the same event, every camera runs a little different time, and then I use it to increment/decrement the timestamps so that all pictures' timestamps are in sync.

I'm not so much a command line person, though, so I use ExifToolGUI, a Windows UI for ExifTool.

Profile

pne: A picture of a plush toy, halfway between a duck and a platypus, with a green body and a yellow bill and feet. (Default)
Philip Newton

June 2015

S M T W T F S
 12 3456
78910111213
14151617181920
2122232425 2627
282930    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Friday, 2 January 2026 21:23
Powered by Dreamwidth Studios