How to change exif dates to match the file name?

Started by 5267, July 21, 2016, 08:14:43 AM

Previous topic - Next topic

Phil Harvey

Hi Stacy,

Try reading this post to get started.  Also, there is this unfinished ExifTool for dummies page.

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

descotes

#31
I put this really long string in - exiftool "-alldates<${directory}${filemodifydate;s/.* //}" "-alldates<${directory}${modifydate;s/.* //}" "-alldates<${directory}${createdate;s/.* //}" "-alldates<${directory}${datetimeoriginal;s/.* //}" -r DIR

And it's doing something

This is a couple examples of the way my file is structured if that helps.  I have a bunch of files where I don't know the exact date and substituted the day for "xx".  I seem to be getting errors on those.  Is there a way I can specify the date I want those to be one by one?  Also it only seems to be giving errors on the Modifydate. Not sure if everything else is working

J:\Pictures\1986\12-25-86 - Christmas
J:\Pictures\1994\05-01-94 - Camping trip

Update:  I stopped it from running.  I went to look at a folder and all it seemed to be doing was adding another file on.  The dates weren't changed on anything that it had gone through already.  I added another attachment for you to see.

Phil Harvey

Try running it on one file with the -v2 option to see some details about what it is doing.

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

descotes

Quote from: Phil Harvey on November 25, 2017, 05:16:33 PM
Try running it on one file with the -v2 option to see some details about what it is doing.

- Phil

What does that mean?  What is a -v2 option?  I want to change all the dates I believe

Phil Harvey

I meant this:

exiftool "-alldates<${directory}${filemodifydate;s/.* //}" "-alldates<${directory}${modifydate;s/.* //}" "-alldates<${directory}${createdate;s/.* //}" "-alldates<${directory}${datetimeoriginal;s/.* //}" -r -v2 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 ($).

jerryb

Hello.  I'm not a code guy so some guidance is greatly appreciated.  It seems that my concern has been addressed in this thread, but I'm hoping I can get a precise copy and paste command to perform this.

I have installed the ExifTool application on my MAC.

Issue:  Embedded dates are all wrong after copying them from platform to platform.  Thankfully the date in the filename is correct.  The filename format is IMG-20141222-WA0054.jpg 

Required:  Copy the date from filename to the exif info.  I've got 2500+ pictures in one folder on my laptop.

Can someone please provide me with a command I can copy paste on my MAC to execute this?

Again.  Forgive the ignorance.  Just a guy who messed up 2500+ family pics, and trying to get back on the wife's good side.

Jerry


Phil Harvey

Hi Jerry,

Embedded dates should not change if you are just copying the file across platforms.

However, filesystem dates are likely to change.  To set the file system modification date from the file name, try this:

exiftool "-filemodifydate<filename" DIR

Note that this will also set the time, which will be 00:54 with your example file 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 ($).

jerryb

Thanks Phil.  I'm an idiot clearly.  All the images are in a folder called SD on the harddrive called HDD6.  So the directory should be HDD6/SD right?
I am getting an error.  I've attached a screenshot of the terminal window.

Thanks,

Jerry


Phil Harvey

Instead of typing the folder name, try dragging and dropping the folder onto the Terminal window.

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

domc43

Hello,

I'm getting an error for some reason which is not letting me update the date information. command log is below. Can you assist? I'm trying to update all Dates with the date in the filename. not sure what the issue is.

C:\Users\Dominic>exiftool "-alldates<filename" C:\Testbatch\IMG_20140508_224323.
jpg
Warning: Invalid EXIF text encoding for UserComment - C:/Testbatch/IMG_20140508_
224323.jpg
Warning: [minor] Entries in IFD0 were out of sequence. Fixed. - C:/Testbatch/IMG
_20140508_224323.jpg
Error: Error reading OtherImageStart data in ExifIFD - C:/Testbatch/IMG_20140508
_224323.jpg
    0 image files updated
    1 files weren't updated due to errors

C:\Users\Dominic>exiftool "-alldates<filename" -v2 C:\Testbatch\IMG_20140508_224
323.jpg
======== C:/Testbatch/IMG_20140508_224323.jpg
Setting new values from C:/Testbatch/IMG_20140508_224323.jpg
Writing MIE-Doc:DateTimeOriginal
Writing Kodak:DateTimeOriginal if tag exists
Writing CanonRaw:DateTimeOriginal if tag exists
Writing Reconyx:DateTimeOriginal if tag exists
Writing XMP-exif:DateTimeOriginal if tag exists
Writing ExifIFD:DateTimeOriginal
Writing PNG:CreateDate
Writing QuickTime:CreateDate if tag exists
Writing PDF:CreateDate if tag exists
Writing PostScript:CreateDate
Writing MIE-Doc:CreateDate
Writing XMP-xmp:CreateDate if tag exists
Writing ExifIFD:CreateDate
Writing PDF:ModifyDate if tag exists
Writing PNG:ModifyDate
Writing PostScript:ModifyDate
Writing MIE-Doc:ModifyDate
Writing QuickTime:ModifyDate if tag exists
Writing XMP-xmp:ModifyDate if tag exists
Writing IFD0:ModifyDate
Warning: Invalid EXIF text encoding for UserComment - C:/Testbatch/IMG_20140508_
224323.jpg
Rewriting C:/Testbatch/IMG_20140508_224323.jpg...
  Editing tags in: APP0 APP1 CIFF ExifIFD IFD0 JFIF MIE-Doc MakerNotes PDF PNG P
ostScript QuickTime XMP
  Creating tags in: APP1 ExifIFD IFD0 MIE-Doc PNG PostScript
JPEG APP1 (831 bytes):
  Rewriting IFD0
  Warning = [minor] Entries in IFD0 were out of sequence. Fixed.
    - IFD0:ModifyDate = '1969:12:31 16:00:00'
    + IFD0:ModifyDate = '2014:05:08 22:43:23'
  Rewriting ExifIFD
    + ExifIFD:DateTimeOriginal = '2014:05:08 22:43:23'
    + ExifIFD:CreateDate = '2014:05:08 22:43:23'
  Error = Error reading OtherImageStart data in ExifIFD
Warning: [minor] Entries in IFD0 were out of sequence. Fixed. - C:/Testbatch/IMG
_20140508_224323.jpg
Error: Error reading OtherImageStart data in ExifIFD - C:/Testbatch/IMG_20140508
_224323.jpg
    0 image files updated
    1 files weren't updated due to errors

C:\Users\Dominic>

Phil Harvey

Hi Dominic,

The metadata in your image is seriously messed up if it has OtherImage tags in the ExifIFD.  See FAQ 20 for how to repair this.

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

thumperstrauss

I scanned old photos where the filename structure is YYYY-MM-DD or YYYY-MM, depending on whether I knew the exact day. In order to keep the photos in order by filename, I sometimes added a letter after the month. See examples of the three kinds of ways photos are named:

1983-04 Pre-birthday setup 001.jpg
1983-04 Pre-birthday setup 002.jpg

1983-04b Birthday 001.jpg
1983-04b Birthday 002.jpg

1987-09-15 Baseball game 001.jpg
1987-09-15 Baseball game 002.jpg

QUESTION: Can you recommend a command line to enable me to change the creation day and make it flexible enough that it won't require a "DD" information if I haven't included it. (Or just default the DD to, "01" if nothing is provided.

Thanks.

Phil Harvey

What do you mean by "change the creation day"?  To set the fileCreateDate from the fileName, you could do this:

exiftool "-filecreatedate<$filename 01 00:00:00" DIR

This would take as much of the date/time from the file name as possible, then add DD HH:MM:SS = "01 00:00:00" if only YY:MM were given, or add HH:MM:SS = "01:00:00" if YY:MM:DD were given.

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

StarGeek

The image count number is going to mixed in there as well, so that needs to be taken into account or stripped away.

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Phil Harvey

Right.  Maybe like this:

exiftool "-filecreatedate<${filename;s/ .*//} 01 00:00:00" DIR
...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 ($).