SCAN in TIFF Files Trying to Overwrite CREATE Date Using File Name

Started by KevnDale, October 29, 2023, 06:04:23 PM

Previous topic - Next topic

KevnDale

I did research and thought this
exiftool -n '-alldates<filename' /FILEPATH

Would overwrite the created date with the file name year. These are scanned in files so I utilized YYYY_Description for most files as I wasnt able to determine an exact month/day. Some do have YYYYMMDD but those are in the minority. When I run the script it says "Updated 1 file" in my test directory but it also creates a duplicate with a .original at the end but the created date isnt changed for either one.

I've reached the end of googling and I am sure it is a simple fix but I cant figure it out.

Any help would be greatly appreciated.

Phil Harvey

When a file is modified, the original file is preserved with "_original" added to the name unless the -overwrite_original option is used.

The AllDates tag writes CreateDate, ModifyDate and DateTimeOriginal.  You may want to change other dates in the video.  See FAQ 3 for help with this.

ExifTool will only set a date from a file name if it contains year (4 digits) and month,day,hour,minute,second (2 digits each).  For partial dates, you can do this (to set CreateDate for example):

exiftool '-createdate<${filename}:00:00 00:00:00' DIR

Note that you can't use the -n option because that would defeat the date/time format parsing.

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

KevnDale

Thank you so I attempted your code and I got:
Warning: No writable tags set from filename
1 image file unchained..


Is this because it is a scan/tiff file?

StarGeek

Quote from: KevnDale on October 29, 2023, 06:29:23 PMIs this because it is a scan/tiff file?

No, exiftool can write to tiff files.

Make sure you are not including the -n (--printConv) option, as that will mess things up.

Are there any numbers in the filename other than the year, month and date?  That will also cause problems.
"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

StarGeek

Quote from: Phil Harvey on October 29, 2023, 06:22:05 PMexiftool '-createdate<${filename}:00:00 00:00:00' DIR

That fails because of 00 month and 00 day.  And if there was a copy number as part of the filename, that would also cause problems.

Dang it, I had a command that worked for if it was only Year, YearMonth, or YearMonthDay, but I can't find it atm.
"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

KevnDale

No other numbers in this test file (some do in my larger file selection)

It is YYYY_Description (No #s), I can remove them from the batch if it causes confusion.

StarGeek

Quote from: KevnDale on October 29, 2023, 07:27:58 PMI can remove them from the batch if it causes confusion.

No need, this command should work.

Not my post I was looking for, but found this post from Phil.  It just needed a little tweak for this situation.

Try this
exiftool -overwrite_original '-AllDates<${filename; my @a=(m/(\d{4})(\d\d)?(\d\d)?/); $a[1] or $a[1]='01';$a[2] or $a[2]='01';$_="$a[0]:$a[1]:$a[2] 00:00:00"}' /path/to/files/

Example output, I had to change the quotes to work on Windows
C:\>exiftool -echo "Clear AllDates" -P -overwrite_original -alldates= Y:\!temp\x\y
Clear AllDates
    1 directories scanned
    3 image files updated

C:\>exiftool -overwrite_original "-AllDates<${filename; my @a=(m/(\d{4})(\d\d)?(\d\d)?/); $a[1] or $a[1]='01';$a[2] or $a[2]='01';$_=\"$a[0]:$a[1]:$a[2] 00:00:00\"}" Y:\!temp\x\y
    1 directories scanned
    3 image files updated

C:\>exiftool -G1 -a -s -AllDates Y:\!temp\x\y
======== Y:/!temp/x/y/2020 Description 01.tif
[ExifIFD]       DateTimeOriginal                : 2020:01:01 00:00:00
[ExifIFD]       CreateDate                      : 2020:01:01 00:00:00
[IFD0]          ModifyDate                      : 2020:01:01 00:00:00
======== Y:/!temp/x/y/202005 Description 02.tif
[ExifIFD]       DateTimeOriginal                : 2020:05:01 00:00:00
[ExifIFD]       CreateDate                      : 2020:05:01 00:00:00
[IFD0]          ModifyDate                      : 2020:05:01 00:00:00
======== Y:/!temp/x/y/20200515 Description 03.tif
[ExifIFD]       DateTimeOriginal                : 2020:05:15 00:00:00
[ExifIFD]       CreateDate                      : 2020:05:15 00:00:00
[IFD0]          ModifyDate                      : 2020:05:15 00:00:00
    1 directories scanned
    3 image files read
"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

KevnDale

You are a legend! Worked like a champ! Month and day came over when i populated. Awesome thank you so much!!

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