How to change exif dates to match the file name?

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

Previous topic - Next topic

thumperstrauss

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

* 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).

thumperstrauss

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

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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).


thumperstrauss

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



Quote from: thumperstrauss 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.

thumperstrauss

@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

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.



* 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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

JAM

Quote
exiftool "-alldates<$directory 00:00:00" -r DIR


Hi Phil,

I'm just starting with exiftool. I have photos with the following date formats and I would like to put those dates into the EXIF info. I don't care about times:

20170423_155550_resized.jpg
2017-02-04_20-46-15.jpg
20180506_xxxxxxxx_LowRes.jpg
IMG-20180302-WA0000.jpg

On the whole directory, I've tried:
exiftool "-alldates<$directory 00:00:00" -r
and
exiftool "-alldates<$filename"

...both followed by the directory name, of course. For the first command, I get:
Warning: Invalid tag name '00:00:00' filename
and
Warning: No writable tags set from filename

For the second, I get:
Warning: No writable tags set from filename


Would you please help me get started on this?

Phil Harvey

Are you on a Mac?  If so, use single quotes instead of double quotes.

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

JAM

Thanks!

Is there a way that I can do it more dangerously--that does not leave the original files behind and tagged with ".original"?

Phil Harvey

You can add -overwrite_original to the command.

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

JAM

Great. Thanks for all of the work you do and help you provide.