Can ExifTool write just the time without date?

Started by kbellis, January 18, 2014, 01:50:24 PM

Previous topic - Next topic

kbellis

Howdy,

Is it possible for ExifTool to write just the time without including the date?

For example, instead of writing:
2013:01:25 08:06:04

only the time would be written out to the out.txt
08:06:04

And then on a related matter, could ExifTool write out just the date into its own field without the time?

Thanks!

Kelly

Phil Harvey

Hi Kelly,

There are different ways to do this depending on exactly what you want to do, but the technique that works in all cases is to use a config file to create user-defined Composite tags to isolate the date and time.  The conversions could look like this:

ValueConv => '$val =~ s/ .*//; $val',   # return the date from a date/time string

and

ValueConv => '$val =~ s/.* //; $val',   # return the time from a date/time string

- 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 ($).

kbellis

Phil - Thank you for the quick reply.

While I've solved this through formulas in the OpenOffice Calc spreadsheet, I'm still very interested in learning how to do this straight up in ExifTool.

Is this then how the .ExifTool_config file should look:

<snip>
#               For detailed information on the definition of tag tables and
#               tag information hashes, see lib/Image/ExifTool/README.
#------------------------------------------------------------------------------
# Saturday, January 18, 2014, 3:47 PM, VKB
# breakup date and time

ValueConvDate => '$val =~ s/ .*//; $val',   # return the date from a date/time string

ValueConvTime => '$val =~ s/.* //; $val',   # return the time from a date/time string


# Shortcut tags are used when extracting information to simplify
# commonly used commands.  They can be used to represent groups

<snip>

And then (wild stab) implementation in the .bat...

echo "FileName<tab>Date<tab>Time<tab>ShutterSpeed<tab>Aperture<tab>ISO" > %1\out.txt
C:\ExifTool\exiftool -T -r -n -filename -dateTimeOriginal -ValueConvDate  -dateTimeOriginal -ValueConvTime   -shutterspeedvalue -aperturevalue -ISO %1 >> %1\out.txt


...well, that didn't work - probably for multiple reasons ;)

File Placement
C:\ExifTool\filename_date_time_exposuretime_aperture_iso.bat
C:\ExifTool\exiftool.exe
C:\ExifTool\.ExifTool_config

...and (wild stab) variants aren't working either.

Thanks for any more pointers.

Kelly





Phil Harvey

Hi Kelly,

Take a look at the Composite tag definitions in the sample config file I linked from my last post.  Your config file should contain definitions like these.  Search for "UserDefined" and "Composite" in this forum for lots more examples.

- 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 ($).

kbellis

Hi Phil,

I think I'm getting closer, but still no cigar.

In the batch file I've tried both ways of not including / including the explicit call to the Exif_config; i.e.,:
echo "BaseName<tab>Date<tab>Time<tab>ShutterSpeed<tab>Aperture<tab>ISO" > %1\out.txt
C:\ExifTool\exiftool -config ExifTool_config -T -r -n -basename -date -time -shutterspeedvalue -aperturevalue -ISO %1 >> %1\out.txt


and in the .ExifTool_config I've made these insertions:
  # Composite tags are added to the Composite table:
    'Image::ExifTool::Composite' => {
        # Composite tags are unique:  The Require/Desire elements specify
        # tags that must/may exist, and the keys of these hashes are used as
        # indices in the @val array of the ValueConv expression to access
        # the numerical (-n) values of these tags.  All Require'd tags must
        # exist for the Composite tag to be evaluated.  If no Require'd tags
        # are specified, then at least one of the Desire'd tags must exist.
        # See the Composite table in Image::ExifTool::Exif for more
        # examples, and lib/Image/ExifTool/README for all of the details.
        # --------------------------------------------------------------
        # With many thanks to Phil Havey
        # Sunday, January 19, 2014, 10:10 AM, VKB
# breakup date and time
# see thread: https://exiftool.org/forum/index.php/topic,5560.0.html
#
        # return the date from a date/time string
        Date => {
    Require => {
                0 => 'DateTimeOriginal',
    ValueConv => '$val =~ s/ .*//; $val',
        },
        # return the time from a date/time string
Time => {
    Require => {
                0 => 'DateTimeOriginal',
    ValueConv => '$val =~ s/.* //; $val',
        },
        #       
        # It's all Phil from here
        BaseName => {
            Require => {


Dragging and dropping a folder onto the bat produces null values at the three composite tag slots including BaseName, one already in the example config file:
"BaseName<tab>Date<tab>Time<tab>ShutterSpeed<tab>Aperture<tab>ISO"
- - - 0.0249999681652841 6.29999084227844 800
- - - 0.0249999681652841 6.29999084227844 800
- - - 0.00999997453917498 6.29999084227844 1600
- - - 0.0666666540332989 10.0000127304368 100
- - - 0.0399998981566999 8 100
- - - 0.00799996944425685 8 400
- - - 0.00124999681739687 5.60000399547274 1600


As stated earlier, the config file is in the same directory as the executable. And I'm using TextPad for editing, ANSI code set.

What might I try next?


kbellis

Phil - after I uploaded the attachment which included the config file, I removed the last line, the remnant from the bottom of this page:
https://exiftool.org/config.html

Phil Harvey

Hi Kelly,

Very close, but with your config file you should have got an error message like this:

syntax error at .ExifTool_config line 249, near ")"

If you didn't get this error, then maybe your config file wasn't in the proper directory.  Try loading it with the -config option (must be first on the command line).

The syntax problem is that the braces in your config file are not balanced.  You have left out the closing brace for each of the "Require" definitions.  It should look like this:

        Date => {
    Require => {
                0 => 'DateTimeOriginal',
            },
    ValueConv => '$val =~ s/ .*//; $val',
        },
        # return the time from a date/time string
Time => {
    Require => {
                0 => 'DateTimeOriginal',
            },
    ValueConv => '$val =~ s/.* //; $val',
        },


- 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 ($).

kbellis

Thanks for the pointers - braces balanced now... but still no luck.

As I mentioned earlier, I've included the explicit call call as shown in the .bat (above) and it didn't work. FWIW, the syntax error message never appeared either.

Beneath C:\ExifTool

kbellis

Phil,

In experiments this morning I tried something new. First using a larger set of test images: 1.44 GB, 120 images (instead of (7)). And then saving .ExifTool_config in a different format; i.e., starting with the file format for the PC encoded ANSI; UNIX encoded UTF-8; PC encoded UTF-8; back to PC encoded ANSI none of which had any different results but all of which allowed the little DOS window to linger visible long enough to read (and capture) and all which reported that the config file was not found.


Of course this still makes no sense since it has always been in the same directory since the getgo but it is at least another clue to go on.

kbellis

Phil,

In other experiments I've named .ExifTool_config using TextPad's Save As option and via the command line route - neither of which had any effect.

Kelly

kbellis

Here's another possible clue and a little background behind it.

I love TextPad and all of the amazing stuff it does including easy syntax highlighting and to do so I created a document class called Perl and am using TextPad's default color scheme for Perl.

I had previously associated the file type .ExifTool_config with the TextPad application overtly through both TextPad and Windows. Then in Windows Explorer double clicking .ExifTool_config would immediately open up TextPad, but the strange part was each time having to overtly turn syntax highlighting on... until I tried renaming .ExifTool_config to m.ExifTool_config - an arbitrary prefix. Then when double clicking on the file, TextPad colors the text - an interesting effect.. and maybe another clue?

FWIW - my machine: Win 7 64-bit

Phil Harvey

If your exiftool command has -config ExifTool_config, then there must be a file named "ExifTool_config" in the current working directory.  Does it show up when you type "dir ExifTool_config"?  If not, you must specify the proper path.

- 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 ($).

kbellis


Yes.

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\ExifTool>dir
Volume in drive C has no label.
Volume Serial Number is BA85-76D5

Directory of C:\ExifTool

01/20/2014  07:36 AM    <DIR>          .
01/20/2014  07:36 AM    <DIR>          ..
01/20/2014  06:03 AM            14,064 .ExifTool_config
01/19/2014  07:12 PM               219 basename_date_time_exposuretime_aperture_iso.bat
01/20/2014  07:37 AM             1,392 Command Prompt.lnk
01/19/2014  11:44 AM             5,006 CompositeQuandary.zip
01/11/2014  06:44 AM         5,158,505 exiftool -k.exe
01/12/2014  10:31 AM         3,738,157 exiftool-9.46.zip
01/11/2014  06:44 AM         5,158,505 exiftool.exe
01/08/2013  08:04 PM         2,936,832 ExifToolGUI.exe
01/12/2014  12:01 PM               830 ExifToolGUI.ini
12/30/2009  02:29 PM             3,636 ExifToolGUI.txt
01/12/2014  10:42 AM           736,806 exiftoolgui.zip
01/12/2014  12:06 PM         1,390,188 exiftoolgui515.zip
01/19/2014  10:36 AM             1,442 ExifToolGUIv5.ini
04/30/2012  08:43 PM             2,399 ExifToolGUI_readme.txt
01/18/2014  11:19 AM               121 filename_aperture_iso.bat
01/19/2014  02:11 PM               196 filename_datetime_exposuretime_aperture_iso.bat
01/19/2014  11:25 AM               219 filename_date_time_exposuretime_aperture_iso.bat
01/18/2014  01:06 PM               192 filename_exposuretime_aperture_iso.bat
01/19/2014  09:02 AM    <DIR>          Image-ExifTool-9.46
01/18/2014  12:45 PM         3,725,846 Image-ExifTool-9.46.tar.gz
01/20/2014  06:08 AM    <DIR>          images
10/12/2009  11:59 AM    <DIR>          jhead_jpegtran
01/12/2014  12:07 PM    <DIR>          workspace
01/12/2014  05:26 PM        10,265,468 _5D34740.CR2
01/12/2014  05:26 PM        10,265,468 _5D34740.CR2_original
              21 File(s)     43,405,491 bytes
               6 Dir(s)  1,059,002,482,688 bytes free

C:\ExifTool>

Phil Harvey

The file is named ".ExifTool_config", but in your screen dump you typed "ExifTool_config" (no dot).  You need to type the exact name.

- 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 ($).

kbellis