ExifTool Forum

ExifTool => Newbies => Topic started by: James Penner on July 16, 2014, 08:57:39 PM

Title: Date formatting
Post by: James Penner on July 16, 2014, 08:57:39 PM
Hello,

I'm trying to add the current date and some text to the Title field in a pdf. I've got no problem doing that, but the date appears like 20140716. Is there a way to format the date so it takes the form: Wednesday,  July 16, 2014?
Title: Re: Date formatting
Post by: Hayo Baan on July 17, 2014, 03:53:47 AM
Hi James,

To make the dates come out in a specific format, use the -d option. In your case you probably want -d "%A, %B %e, %Y"

To add some text and the create datetime of the file in the title of the file, you can now use the following:
exiftool -d "%A, %B %e, %Y" "-Title<$Title Some Text – $CreateDate – Some more text" <file>
(on a Mac, use single quotes).

Hope this helps,
Hayo
Title: Re: Date formatting
Post by: Phil Harvey on July 17, 2014, 07:10:04 AM
Just one point to add.  You can use the Now tag if you want the current date/time.  So Hayo's command would be:

exiftool -d "%A, %B %e, %Y" "-Title<$Title Some Text – $Now – Some more text" <file>

- Phil
Title: Re: Date formatting
Post by: James Penner on July 17, 2014, 07:25:24 PM
Thank you Hayo and Phil for your responses.

I tried using the command with a slight modification (removing $Title):

exiftool -d "%A, %B %e, %Y" "-Title<Some Text – $Now – Some more text" *.pdf

And I get:

Some Text ? B Y ? Some more text

Any ideas as to why I'd be getting this result?


Title: Re: Date formatting
Post by: Hayo Baan on July 18, 2014, 04:23:58 AM
Are you on windows or a Mac? On a mac, you should use single quotes (at least for the second part). On windows the problem may be the endash (–), a unicode charater, I used in my example. It may be that windows does not support those properly (hence the question marks). That doesn't explain the B and Y, but it may be related...

Title: Re: Date formatting
Post by: James Penner on July 18, 2014, 11:47:51 AM
Hi Hayo,

I'm on Windows, and it looks like that's why I was having the issues. Removing the endashes helped. I also used double per cent signs, and that seemed to work.

Now, if I use:

exiftool -d "%%A, %%B %%d, %%Y" "-Title<Some Text $Now Some more text" *.pdf

I get:

Some Text Friday, July 18, 2014 Some more text

Thank you very much for your help!
Title: Re: Date formatting
Post by: Phil Harvey on July 18, 2014, 11:51:50 AM
You must be running from a .bat file for the double "%" to be necessary.

It is very difficult to give accurate advice without knowing details like this (and your system).

- Phil
Title: Re: Date formatting
Post by: James Penner on July 18, 2014, 02:00:09 PM
Yes, you're correct Phil, I am running the command through a batch file. Sorry I didn't include that. I'd forgotten it makes a difference. I can appreciate it makes things a lot more difficult without all the information, and I'll try to remember to include everything next time. Thanks again to both of you for your help and patience.