Author Topic: How to change exif dates to match the file name?  (Read 16823 times)

thumperstrauss

  • Newbie
  • *
  • Posts: 5
Re: How to change exif dates to match the file name?
« Reply #45 on: June 05, 2018, 07:37:25 PM »
It worked! The photos with the same month (1984-02) have the same creation date (1984-02-01 12:00:00AM) Is there way to make the add a second between the photos to try to mimic the filename numbering? The idea is to "trick" Google Photos into putting the photos into the correct order. Otherwise, I fear Google Photos will jumble the order as it doesn't seem to pay any attention to the filename.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2365
Re: How to change exif dates to match the file name?
« Reply #46 on: June 05, 2018, 10:17:50 PM »
See this post.   You've already done step one.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

thumperstrauss

  • Newbie
  • *
  • Posts: 5
Re: How to change exif dates to match the file name?
« Reply #47 on: June 10, 2018, 04:59:18 PM »
For future me, here are the two steps that worked (thanks to Phil Harvey and Star Geek):

1. Scan photos
2. Name them like this: 1984-02 Birthday 001.tif, 1984-02 Birthday 002.tif, 1989-08 Vacation 001.tif, etc.
3. Place exiftool in Windows system directory (follow installation info)
4. Open Command prompt (in Windows 10)
5. Type the following: exiftool "-filecreatedate<${filename;s/ .*//} 01 00:00:00" c:/testphotos (where c:/testphotos is the location of the folder... folder with spaces seems more troublefree, but need to look into this...)
6. Type the following: exiftool "-datetimeoriginal+<0:$filesequence" c:/testphotos

This changes the creation date and forces Google photos to place the images in the correct order.

arcanjl

  • Newbie
  • *
  • Posts: 2
Re: How to change exif dates to match the file name?
« Reply #48 on: October 02, 2018, 12:56:23 PM »
I have tried a bunch, an I think I might have gotten close, but then started to fall behind. My problem seems so much more simple then the above, but I can't get it to work.
I don't have folders, I have all my images in one folder with only the year (while scanning I had no idea on the finer details).

JPG Name:
1967 Uncle Frank

I would like to take that date (year) and out it in the DateTaken Meta. Date taken seems to be better than Date created, would you disagree? At least with date created I have a record when I scanned it.


Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14405
    • ExifTool Home Page
Re: How to change exif dates to match the file name?
« Reply #49 on: October 02, 2018, 01:04:31 PM »
Assuming you mean "DateTimeOriginal" for what you call "DateTaken", you could try this:

exiftool "-datetimeoriginal<${filename;$_=/^(\d{4})/ ? $1 . ':01:01 00:00:00' : undef}" DIR

This should write a DateTimeOriginal of "1967:01:01 00:00:00" to your example file, and it will only update files with names that begin with 4 digits.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

arcanjl

  • Newbie
  • *
  • Posts: 2
Re: How to change exif dates to match the file name?
« Reply #50 on: October 02, 2018, 02:35:24 PM »
 :D :D :D :D :D
Thank you Thank you!!!!

thumperstrauss

  • Newbie
  • *
  • Posts: 5
Re: How to change exif dates to match the file name?
« Reply #51 on: March 09, 2019, 10:03:05 PM »
Slight update for future me. Step 6 has been slightly updated. The correct procedure is this:

1. Scan photos
2. Name them like this: 1984-02 Birthday 001.tif, 1984-02 Birthday 002.tif, 1989-08 Vacation 001.tif, etc.
3. Place exiftool in Windows system directory (follow installation info)
4. Open Command prompt (in Windows 10)
5. Type the following: exiftool "-filecreatedate<${filename;s/ .*//} 01 00:00:00" c:/testphotos
6. Then after step 5 finishes, type the following: exiftool "-filecreatedate+<0:$filesequence" c:/testphotos



For future me, here are the two steps that worked (thanks to Phil Harvey and Star Geek):

1. Scan photos
2. Name them like this: 1984-02 Birthday 001.tif, 1984-02 Birthday 002.tif, 1989-08 Vacation 001.tif, etc.
3. Place exiftool in Windows system directory (follow installation info)
4. Open Command prompt (in Windows 10)
5. Type the following: exiftool "-filecreatedate<${filename;s/ .*//} 01 00:00:00" c:/testphotos (where c:/testphotos is the location of the folder... folder with spaces seems more troublefree, but need to look into this...)
6. Type the following: exiftool "-datetimeoriginal+<0:$filesequence" c:/testphotos

This changes the creation date and forces Google photos to place the images in the correct order.

thumperstrauss

  • Newbie
  • *
  • Posts: 5
Re: How to change exif dates to match the file name?
« Reply #52 on: March 09, 2019, 11:50:56 PM »
@PhilHarvey I'm having a weird problem. I'm using the following two commands, one at a time in order to se the filecreatedate to grab the date from the file name (2010-02 party 01.jpg). It works, but all my files from 1968 and 1969 (that's where my files begin) turn into 2068 and 2069. Everything from 1970 onwards resolves okay. Any idea what this could be? I just installed the latest exiftool (exiftool-11.31) and tried again, but same result.

exiftool "-filecreatedate<${filename;s/ .*//} 01 00:00:00" c:/testphotos
exiftool "-filecreatedate+<0:$filesequence" c:/testphotos

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2365
Re: How to change exif dates to match the file name?
« Reply #53 on: March 10, 2019, 12:18:24 AM »
Previous threads on the subject:
Interesting results changing file system dates 1969 to 1968, and 1980 to 1979
Use of FileModifyDate not working in my batch job
Windows FileAccessDate, FileCreateDate, and FileModifyDate wrong century

tl;dr,
ExifTool uses standard Perl date/time routines to do the necessary conversions.  These routines are based on an epoch date of 1970, and the behaviour before that can be funny.  Exiftool cannot properly set file system dates between 1900:01:01 00:00:00 and 1968:12:31 23:59:59.



Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14405
    • ExifTool Home Page
Re: How to change exif dates to match the file name?
« Reply #54 on: March 10, 2019, 09:27:25 AM »
StarGeek is correct.

And a FileCreateDate of before 1970 is not physical, and won't be supported by many filesystems anyway.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).