adding EXIF datetime to Narrative Clip jpegs

Started by chuckkahn, May 10, 2014, 09:06:26 PM

Previous topic - Next topic

chuckkahn

The Narrative Clip camera syncs its EXIF-less photos locally to sub-directories in the format of YYYY/MM/DD, with a filename in the format of hhmmss.  I have yet to figure out how to tell Exiftool to transfer this directory and filename data into the jpegs.  I tried this on a copy of one of the jpegs which I named "210506c.jpg":

exiftool "-datetimeoriginal<{directory}filename" ~/Pictures/Narrative\ Clip/2014/05/02/210506c.jpg

To which Exiftool responded:

Warning: No writable tags set from /Users/chuckkahn/Pictures/Narrative Clip/2014/05/02/210506c.jpg
    0 image files updated
    1 image files unchanged


Another attempt went:

exiftool "-datetimeoriginal<${directory}filename" /Users/chuckkahn/Pictures/Narrative\ Clip/2014/05/02/210506c.jpg

Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in ExifIFD:DateTimeOriginal (PrintConvInv) - /Users/chuckkahn/Pictures/Narrative Clip/2014/05/02/210506c.jpg
    1 image files updated


I could list more of my attempts made this afternoon, but the results were all negative.   How can I get this to work?

P.S.: I should mention that the hhmmss.jpg filename format is UTC time.  (I'm in EDT time.)  Just getting either time to work would seem like an achievement.


StarGeek

The error message of "Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in ExifIFD:DateTimeOriginal" pretty much tells you the problem.  You're trying to put the entire directory and filename, which is "/Users/chuckkahn/Pictures/Narrative Clip/2014/05/02/210506c.jpg" when the tag wants it in the format of YYYY:mm:dd HH:MM:SS. 

Ok, this is messy but my quick test looks like it should work.  It uses some of the advanced formatting to capture and backreference the parts of the directory and filename you want and then format it properly.  I think I might be missing an easier way to do it and if so, Phil will probably come along and fix it :D

ExifTool "-datetimeoriginal<${directory;s!([0-9]{4})/([0-9]{2})/([0-9]{2})$!\1:\2:\3!} ${filename;s!([0-9]{2})([0-9]{2})([0-9]{2})!\1:\2:\3!}" /Users/chuckkahn/Pictures/Narrative\ Clip/2014/05/02/210506c.jpg

Edit: slight change to force directory regex to match end of directory.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

chuckkahn

Quote from: StarGeek on May 11, 2014, 02:04:54 AM
The error message of "Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in ExifIFD:DateTimeOriginal" pretty much tells you the problem.  You're trying to put the entire directory and filename, which is "/Users/chuckkahn/Pictures/Narrative Clip/2014/05/02/210506c.jpg" when the tag wants it in the format of YYYY:mm:dd HH:MM:SS. 

Ok, this is messy but my quick test looks like it should work.  It uses some of the advanced formatting to capture and backreference the parts of the directory and filename you want and then format it properly.  I think I might be missing an easier way to do it and if so, Phil will probably come along and fix it :D

ExifTool "-datetimeoriginal<${directory;s!([0-9]{4})/([0-9]{2})/([0-9]{2})$!\1:\2:\3!} ${filename;s!([0-9]{2})([0-9]{2})([0-9]{2})!\1:\2:\3!}" /Users/chuckkahn/Pictures/Narrative\ Clip/2014/05/02/210506c.jpg

Edit: slight change to force directory regex to match end of directory.

Thanks for the help.  That gets:

event not found

I hoped it would be much simpler based on Phil's reply in this thread, where the path began with "c:\images\" and didn't include the DD or the hhmmss.   

https://exiftool.org/forum/index.php?topic=3807.0


Phil Harvey

It is simpler.  You just forgot a '$' in front of "filename":

exiftool "-datetimeoriginal<${directory}$filename" /Users/chuckkahn/Pictures/Narrative\ Clip/2014/05/02/210506c.jpg

FAQ 5 explains the required date/time formatting.

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

chuckkahn

Quote from: Phil Harvey on May 11, 2014, 07:31:41 AM
It is simpler.  You just forgot a '$' in front of "filename":

exiftool "-datetimeoriginal<${directory}$filename" /Users/chuckkahn/Pictures/Narrative\ Clip/2014/05/02/210506c.jpg

FAQ 5 explains the required date/time formatting.

- Phil

I'll have to read that faq more carefully, but that isn't working either:

exiftool "-datetimeoriginal<${directory}$filename" /Users/chuckkahn/Pictures/Narrative\ Clip/2014/05/02/210506c.jpg

Warning: No writable tags set from /Users/chuckkahn/Pictures/Narrative Clip/2014/05/02/210506c.jpg
    0 image files updated
    1 image files unchanged


Phil Harvey

Ah.  You're on a Mac.  You must use single quotes, not double quotes, around arguments containing a dollar sign.  The double quotes are used on Windows systems.

Unfortunately you are using bash instead of tcsh, or else you would have got this message from the shell:

directory: Undefined variable.

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

chuckkahn

Quote from: Phil Harvey on May 11, 2014, 09:21:36 AM
Ah.  You're on a Mac.  You must use single quotes, not double quotes, around arguments containing a dollar sign.  The double quotes are used on Windows systems.

Unfortunately you are using bash instead of tcsh, or else you would have got this message from the shell:

directory: Undefined variable.

- Phil

Single quotes worked.  Yay!

chuckkahn

Can time be shifted (UTC to my TZ) in  one step or in only via two steps like this?

exiftool '-alldates<${directory}$filename' /Users/chuckkahn/Pictures/Narrative\ Clip/2014/05/02/210506c.jpg
exiftool -alldates-=4 /Users/chuckkahn/Pictures/Narrative\ Clip/2014/05/02/210506c.jpg

Phil Harvey

Hi Chuck,

It does take two steps, but you can combine them into a single command if this is more convenient:

exiftool '-alldates<${directory}$filename' -execute -alldates-=4 -common_args /Users/chuckkahn/Pictures/Narrative\ Clip/2014/05/02/210506c.jpg

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

chuckkahn

Quote from: Phil Harvey on May 11, 2014, 02:58:10 PM
Hi Chuck,

It does take two steps, but you can combine them into a single command if this is more convenient:

exiftool '-alldates<${directory}$filename' -execute -alldates-=4 -common_args /Users/chuckkahn/Pictures/Narrative\ Clip/2014/05/02/210506c.jpg

- Phil

Is there a way to combine them into one step?   I assume each step re-writes the jpeg, so one step would be faster than two?

Would it be faster still (more jpegs updated per minute) to do this using Image::ExifTool in a perl script instead of as a exiftool command-line?

Phil Harvey

Doing this via the API won't speed things up unless you can reduce the number of steps.  But from the command line, you can reduce the steps to the minimum anyway.  You need to create a user-defined tag to do the time shift for you.  Search for UserDefined and ShiftTime in the forum and you should find some examples.  The only trick may be that you might need to fix the formatting of the date/time a bit.  I can't recall how flexible ShiftTime is about the format.

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

chuckkahn

#11
Quote from: Phil Harvey on June 29, 2014, 08:47:39 PM
Doing this via the API won't speed things up unless you can reduce the number of steps.  But from the command line, you can reduce the steps to the minimum anyway.  You need to create a user-defined tag to do the time shift for you.  Search for UserDefined and ShiftTime in the forum and you should find some examples.  The only trick may be that you might need to fix the formatting of the date/time a bit.  I can't recall how flexible ShiftTime is about the format.

- Phil

Is there a syntax for adding more commands?  I tried adding a model tag command plus a -r recursive control after the second alldates but when doing multiple folders (the month folder for may, "05", contains day folders "01", "02", etc), the date functions stop writing after a few day folders and only the model tag gets written with no error message appears illuminating the problem.

exiftool '-alldates<\${directory}\$filename' -execute -alldates-=4 -model='Narrative Clip' -r -common_args -overwrite_original  /Users/chuckkahn/Pictures/Narrative\ Clip/2014/05/ 

P.S.:

adding the "-r" to near the end seems to be working better so far...

exiftool '-alldates<\${directory}\$filename' -execute -alldates-=4 -model='Narrative Clip'  -common_args -overwrite_original -r /Users/chuckkahn/Pictures/Narrative\ Clip/2014/05/

P.P.S:

Spoke too soon.   Doing that negates the -4 hour shift.  Darn.

Phil Harvey

Quote from: chuckkahn on June 30, 2014, 07:26:19 PM
Is there a syntax for adding more commands?  I tried adding a model tag command plus a -r recursive control after the second alldates but when doing multiple folders (the month folder for may, "05", contains day folders "01", "02", etc), the date functions stop writing after a few day folders and only the model tag gets written with no error message appears illuminating the problem.

exiftool '-alldates<\${directory}\$filename' -execute -alldates-=4 -model='Narrative Clip' -r -common_args -overwrite_original  /Users/chuckkahn/Pictures/Narrative\ Clip/2014/05/ 

If you want the -r to apply to the -alldates command, it must come after -common_args.  Read the explanation of -common_args in the documentation for details.

Quoteadding the "-r" to near the end seems to be working better so far...

Yes.

QuoteSpoke too soon.   Doing that negates the -4 hour shift.  Darn.

It shouldn't.

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

chuckkahn

#13

Quote from: chuckkahn on June 30, 2014, 07:26:19 PM
QuoteSpoke too soon.   Doing that negates the -4 hour shift.  Darn.

It shouldn't.

- Phil

If I do it at the date level (2014/05/17) it works if I do it at the month level (2014/05) it doesn't. 

Trying at the month level with fresh files (no dates added yet) seems to work.

======== /Users/chuckkahn/Pictures/Narrative Clip/2014/05/28/235954.jpg
Date/Time Original              : 2014:05:28 19:59:54
Create Date                     : 2014:05:28 19:59:54
Modify Date                     : 2014:05:28 19:59:54


Update: this seems so random;  same command, different directory (June) results in no camera model being set.

exiftool '-alldates<\${directory}\$filename' -execute -alldates-=4 -model='Narrative Clip' -common_args -r -overwrite_original /Users/chuckkahn/Pictures/Narrative\ Clip/2014/06

Update again: Is it executing the portion before the "-execute" on all the files in one step and then executing all the commands after "-execute" as a second step so that when I'm checking while it's doing it I'm not seeing the finished two steps of execution?   (I'm sure there's a better way of wording that but words fail me.)   Is there a way for the exiftool command to display it's progress so that I know where it is (which file, which stage of execution) so that I don't jump to conclusions about it failing?


Phil Harvey

This command

exiftool '-alldates<\${directory}\$filename' -execute -alldates-=4 -model='Narrative Clip' -common_args -r -overwrite_original /Users/chuckkahn/Pictures/Narrative\ Clip/2014/06

is functionally equivalent to these two commands executed in sequence:

exiftool '-alldates<\${directory}\$filename' -r -overwrite_original /Users/chuckkahn/Pictures/Narrative\ Clip/2014/06
exiftool -alldates-=4 -model='Narrative Clip' -r -overwrite_original /Users/chuckkahn/Pictures/Narrative\ Clip/2014/06


The only difference is that you save time by only loading exiftool once.

Quote from: chuckkahn on July 05, 2014, 01:21:18 PM
Is there a way for the exiftool command to display it's progress so that I know where it is (which file, which stage of execution) so that I don't jump to conclusions about it failing?

You could try the -progress option.

This is all explained in the application documentation.

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