News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Date formatting

Started by James Penner, July 16, 2014, 08:57:39 PM

Previous topic - Next topic

James Penner

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?

Hayo Baan

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
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

James Penner

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?



Hayo Baan

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...

Hayo Baan – Photography
Web: www.hayobaan.nl

James Penner

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!

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

James Penner

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.