Copying and also setting create/modify date based on Exif at the same time

Started by JeremyLaurenson, December 06, 2023, 09:36:34 AM

Previous topic - Next topic

JeremyLaurenson

Hi, folks.

First, exiftool kicks butt and has solved a huge issue for me. Bravo!

Now, currently I have exiftool moving media from an incoming directory to the right place based on original create date, falling back to file create date thusly:

/usr/local/bin/exiftool -extractEmbedded -d "%Y/%B" '-directory</Volumes/Pegasus R4i/Photos/$filecreatedate' '-directory</Volumes/Pegasus R4i/Photos/$DateTimeOriginal' "/Volumes/Pegasus R4i/Photos/Incoming" -r


WhatI would like it to do is also make sure the create date/modify date on the target file is set to the exif data too when it copies the file... whats the trick to doing that?

Sincerely

Jeremy

Phil Harvey

Hi Jeremy,

This should do it:

/usr/local/bin/exiftool -extractEmbedded -d "%Y/%B" '-directory</Volumes/Pegasus R4i/Photos/$filecreatedate' '-directory</Volumes/Pegasus R4i/Photos/$DateTimeOriginal' '-filecreatedate<datetimeoriginal' '-filemodifydate<datetimeoriginal' "/Volumes/Pegasus R4i/Photos/Incoming" -r

Also, I don't think the -extractEmbedded option is useful if you are copying only JPG images.  And if you are copying videos, you should probably use CreateDate instead of DateTimeOriginal.

Note that this command will only work on Macintosh or Windows PowerShell, because Windows CMD would require double quotes and Linux doesn't support FileCreateDate.

Also, you said "when it copies the file", but this should move the file without preserving a copy since the file itself is not being modified.

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

JeremyLaurenson

Hmm, theres something not quite right here...

I took this picture at 9:59:56 (Took a pic of the clock on my Mac including seconds)
Its an HEIC, and there is an associated apple .mov file.

I used the command to move/tag images:

/usr/local/bin/exiftool -d "%Y/%B" '-directory</Volumes/Pegasus R4i/Photos/$filecreatedate' '-directory</Volumes/Pegasus R4i/Photos/$CreateDate' '-filecreatedate<datetimeoriginal' '-filemodifydate<datetimeoriginal' "/Volumes/Pegasus R4i/Photos/Incoming" -r


The create and modify date on the moved HEIC file shows Dec 1,2023, 12:00 AM
The create and modify date on the moved MOV file shows Dec 6 1012 10:02am (the date the script was run)

exiftool 78529AAD-5B19-4B5D-AF43-DDE33F791506.heic
ExifTool Version Number         : 12.70
File Name                       : 78529AAD-5B19-4B5D-AF43-DDE33F791506.heic
Directory                       : .
File Size                       : 3.1 MB
File Modification Date/Time     : 2023:12:01 00:00:00-05:00
File Access Date/Time           : 2023:12:06 10:04:54-05:00
File Inode Change Date/Time     : 2023:12:06 10:04:52-05:00
File Permissions                : -rw-r--r--
File Type                       : HEIC
File Type Extension             : heic
MIME Type                       : image/heic
Major Brand                     : High Efficiency Image Format HEVC still image (.HEIC)
Minor Version                   : 0.0.0
Compatible Brands               : mif1, MiHE, MiPr, miaf, MiHB, heic
Handler Type                    : Picture
Primary Item Reference          : 49
Meta Image Size                 : 4032x3024
XMP Toolkit                     : XMP Core 6.0.0
HDR Gain Map Version            : 65536
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : Apple
Camera Model Name               : iPhone 14 Pro
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : 17.1.2
Modify Date                     : 2023:12:06 09:59:36
Host Computer                   : iPhone 14 Pro
Exposure Time                   : 1/120
F Number                        : 2.2
Exposure Program                : Program AE
ISO                             : 100
Exif Version                    : 0232
Date/Time Original              : 2023:12:06 09:59:36
Create Date                     : 2023:12:06 09:59:36
Offset Time                     : -05:00
Offset Time Original            : -05:00
Offset Time Digitized           : -05:00
Shutter Speed Value             : 1/120
Aperture Value                  : 2.2
Brightness Value                : 5.179750249
Exposure Compensation           : 0
Metering Mode                   : Multi-segment
Flash                           : Off, Did not fire
Focal Length                    : 2.2 mm
Subject Area                    : 2050 1441 1387 794
Maker Note Version              : 14
Run Time Flags                  : Valid
Run Time Value                  : 306336045940333
Run Time Scale                  : 1000000000
Run Time Epoch                  : 0
AE Stable                       : Yes
AE Target                       : 198
AE Average                      : 226
AF Stable                       : Yes
Acceleration Vector             : -0.9764910938 -0.04099444301 -0.2134071441
Content Identifier              : F6E1B584-4BBF-4F3B-9CCF-7B2EF3AA9326
Image Capture Type              : Unknown (12)
Live Photo Video Index          : 5283844
HDR Headroom                    : 0.9317608476
Signal To Noise Ratio           : 32.50517275
Photo Identifier                : 54B4450C-1E97-4643-BA82-EC5A23F83EBD
Focus Position                  : 77
HDR Gain                        : 0
AF Measured Depth               : 10
AF Confidence                   : 6
Semantic Style                  : {_0=1,_1=0,_2=0,_3=0}
Front Facing Camera             : No
Sub Sec Time Original           : 072
Sub Sec Time Digitized          : 072
Color Space                     : Uncalibrated
Exif Image Width                : 4032
Exif Image Height               : 3024
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Exposure Mode                   : Auto
White Balance                   : Auto
Digital Zoom Ratio              : 1.775196041
Focal Length In 35mm Format     : 24 mm
Lens Info                       : 2.22-9mm f/1.779999971-2.8
Lens Make                       : Apple
Lens Model                      : iPhone 14 Pro back triple camera 2.22mm f/2.2
Composite Image                 : General Composite Image
GPS removed
Profile CMM Type                : Apple Computer Inc.
Profile Version                 : 4.0.0
Profile Class                   : Display Device Profile
Color Space Data                : RGB
Profile Connection Space        : XYZ
Profile Date Time               : 2022:01:01 00:00:00
Profile File Signature          : acsp
Primary Platform                : Apple Computer Inc.
CMM Flags                       : Not Embedded, Independent
Device Manufacturer             : Apple Computer Inc.
Device Model                    :
Device Attributes               : Reflective, Glossy, Positive, Color
Rendering Intent                : Perceptual
Connection Space Illuminant     : 0.9642 1 0.82491
Profile Creator                 : Apple Computer Inc.
Profile ID                      : ecfda38e388547c36db4bd4f7ada182f
Profile Description             : Display P3
Profile Copyright               : Copyright Apple Inc., 2022
Media White Point               : 0.96419 1 0.82489
Red Matrix Column               : 0.51512 0.2412 -0.00105
Green Matrix Column             : 0.29198 0.69225 0.04189
Blue Matrix Column              : 0.1571 0.06657 0.78407
Red Tone Reproduction Curve     : (Binary data 32 bytes, use -b option to extract)
Chromatic Adaptation            : 1.04788 0.02292 -0.0502 0.02959 0.99048 -0.01706 -0.00923 0.01508 0.75168
Blue Tone Reproduction Curve    : (Binary data 32 bytes, use -b option to extract)
Green Tone Reproduction Curve   : (Binary data 32 bytes, use -b option to extract)
HEVC Configuration Version      : 1
General Profile Space           : Conforming
General Tier Flag               : Main Tier
General Profile IDC             : Main Still Picture
Gen Profile Compatibility Flags : Main Still Picture, Main 10, Main
Constraint Indicator Flags      : 176 0 0 0 0 0
General Level IDC               : 90 (level 3.0)
Min Spatial Segmentation IDC    : 0
Parallelism Type                : 0
Chroma Format                   : 4:2:0
Bit Depth Luma                  : 8
Bit Depth Chroma                : 8
Average Frame Rate              : 0
Constant Frame Rate             : Unknown
Num Temporal Layers             : 1
Temporal ID Nested              : No
Image Width                     : 4032
Image Height                    : 3024
Image Spatial Extent            : 4032x3024
Rotation                        : 0
Image Pixel Depth               : 8 8 8
Auxiliary Image Type            : urn:com:apple:photo:2020:aux:hdrgainmap
Media Data Size                 : 3131285
Media Data Offset               : 3752
Run Time Since Power Up         : 3 days 13:05:36
Aperture                        : 2.2
Image Size                      : 4032x3024
Megapixels                      : 12.2
Scale Factor To 35 mm Equivalent: 10.8
Shutter Speed                   : 1/120
Create Date                     : 2023:12:06 09:59:36.072-05:00
Date/Time Original              : 2023:12:06 09:59:36.072-05:00
Modify Date                     : 2023:12:06 09:59:36-05:00
GPS removed
Circle Of Confusion             : 0.003 mm
Field Of View                   : 73.7 deg
Focal Length                    : 2.2 mm (35 mm equivalent: 24.0 mm)
Hyperfocal Distance             : 0.81 m
Light Value                     : 9.2
Lens ID                         : iPhone 14 Pro back triple camera 2.22mm f/2.2

exiftool 78529AAD-5B19-4B5D-AF43-DDE33F791506_3.mov
ExifTool Version Number         : 12.70
File Name                       : 78529AAD-5B19-4B5D-AF43-DDE33F791506_3.mov
Directory                       : .
File Size                       : 4.4 MB
File Modification Date/Time     : 2023:12:06 10:02:19-05:00
File Access Date/Time           : 2023:12:06 10:02:20-05:00
File Inode Change Date/Time     : 2023:12:06 10:04:52-05:00
File Permissions                : -rw-r--r--
File Type                       : MOV
File Type Extension             : mov
MIME Type                       : video/quicktime
Major Brand                     : Apple QuickTime (.MOV/QT)
Minor Version                   : 0.0.0
Compatible Brands               : qt
Media Data Size                 : 4411917
Media Data Offset               : 36
Movie Header Version            : 0
Create Date                     : 2023:12:06 14:59:36
Modify Date                     : 2023:12:06 14:59:37
Time Scale                      : 600
Duration                        : 2.91 s
Preferred Rate                  : 1
Preferred Volume                : 100.00%
Preview Time                    : 0 s
Preview Duration                : 0 s
Poster Time                     : 0 s
Selection Time                  : 0 s
Selection Duration              : 0 s
Current Time                    : 0 s
Next Track ID                   : 6
Track Header Version            : 0
Track Create Date               : 2023:12:06 14:59:36
Track Modify Date               : 2023:12:06 14:59:37
Track ID                        : 1
Track Duration                  : 2.91 s
Track Layer                     : 0
Track Volume                    : 0.00%
Image Width                     : 1920
Image Height                    : 1440
Clean Aperture Dimensions       : 1744x1308
Production Aperture Dimensions  : 1920x1440
Encoded Pixels Dimensions       : 1920x1440
Graphics Mode                   : ditherCopy
Op Color                        : 32768 32768 32768
Compressor ID                   : hvc1
Source Image Width              : 1920
Source Image Height             : 1440
X Resolution                    : 72
Y Resolution                    : 72
Compressor Name                 : HEVC
Bit Depth                       : 24
Video Frame Rate                : 29.553
Camera Lens Model (und-US)      : iPhone 14 Pro back camera 2.22mm f/2.2
Camera Focal Length 35mm Equivalent (und-US): 13
Balance                         : 0
Audio Format                    : lpcm
Audio Channels                  : 3
Audio Bits Per Sample           : 16
Audio Sample Rate               : 1
Warning                         : [minor] The ExtractEmbedded option may find more tags in the media data
Matrix Structure                : 1 0 0 0 1 0 0 0 1
Content Describes               : Track 1
Media Header Version            : 0
Media Create Date               : 2023:12:06 14:59:36
Media Modify Date               : 2023:12:06 14:59:37
Media Time Scale                : 600
Media Duration                  : 0.00 s
Media Language Code             : und
Gen Media Version               : 0
Gen Flags                       : 0 0 0
Gen Graphics Mode               : ditherCopy
Gen Op Color                    : 32768 32768 32768
Gen Balance                     : 0
Handler Class                   : Data Handler
Handler Vendor ID               : Apple
Handler Description             : Core Media Data Handler
Meta Format                     : mebx
Handler Type                    : Metadata Tags
Location Accuracy Horizontal    : 5.108611
Live Photo Auto                 : 1
Content Identifier              : F6E1B584-4BBF-4F3B-9CCF-7B2EF3AA9326
Live Photo Vitality Score       : 0.939698457717896
Live Photo Vitality Scoring Version: 4
Make                            : Apple
Model                           : iPhone 14 Pro
Software                        : 17.1.2
Creation Date                   : 2023:12:06 09:59:35-05:00
Camera Lens Model               : iPhone 14 Pro back camera 2.22mm f/2.2
Camera Focal Length 35mm Equivalent: 13
Image Size                      : 1920x1440
Megapixels                      : 2.8
Avg Bitrate                     : 12.1 Mbps

PH Edit: Put output in code blocks

Phil Harvey

Right.  I forgot that the -d will also effect the arguments to set FileCreateDate and FileModifyDate.

You need to disable the conversion for the copied tags, and use CreateDate instead of DateTimeOriginal:

/usr/local/bin/exiftool -d "%Y/%B" '-directory</Volumes/Pegasus R4i/Photos/$filecreatedate' '-directory</Volumes/Pegasus R4i/Photos/$CreateDate' '-filecreatedate#<createdate#' '-filemodifydate#<createdate#' "/Volumes/Pegasus R4i/Photos/Incoming" -r

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

JeremyLaurenson

Thanks for all the help....

Image files are being set correctly, but mov files seem to be getting set to GMT timestamp
 

Phil Harvey

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