Re: Set Date Taken from File Name

Started by mak, December 21, 2021, 11:58:03 PM

Previous topic - Next topic

mak

Hello,

I want to fix my whatsapp dates. they go like this "IMG-20151028-WA0000.jpg"
used this command here:
exiftool "-alldates<filename" /path/to/dir

the thing is it only changes the date taken for the pics. can this command be modified to also add the same date from file name so it changes it for  "date modified" and "date created" as well?

Thanks!

StarGeek

Quote from: mak on December 21, 2021, 11:58:03 PM
the thing is it only changes the date taken for the pics. can this command be modified to also add the same date from file name so it changes it for  "date modified" and "date created" as well?

The AllDates shortcut writes the EXIF:CreateDate and EXIF:ModifyDate as will as the EXIF:DateTimeOriginal] tag.  But I'm guessing what you really want to write is the file system timestamps.  To write to those, you would replace AllDates with FileCreateDate/FileModifyDate.  You can do all of them at once with
exiftool "-AllDates<Filename" "-FileCreateDate<Filename" "-FileModifyDate<Filename" /path/to/files/

But in the GUI, you would drop the "exiftool" and path part when setting up the exiftool direct box.
* 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).

mak

Thanks for quick reply.

I ran the command and it changed the  date taken and date modified but there was no affect on date created.
any ideas?
I am checking the changes in w7 windows explorer properties box under details.

Phil Harvey

What is the output of this command on one of the files, and what does Windows Explorer say?:

exiftool -time:all -G1 -a 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 ($).

mak

Please check attachment.

first time running command was for original pic. second time was for updated pic with exiftool.
all dates get updated except for "file creation date/time". I am not sure if that is any problem.

StarGeek

That's very strange.  The FileAccessDate will get changed ever time the file is read, but the FileCreateDate should have been changed.

Here's how it works on my system
C:\>exiftool -time:all -g1 -a -s Y:\!temp\bbbb\img-20151204-wa0002.jpg
---- System ----
FileModifyDate                  : 2021:12:22 07:51:44-08:00
FileAccessDate                  : 2021:12:22 07:51:44-08:00
FileCreateDate                  : 2021:12:22 07:51:44-08:00

C:\>exiftool -P -overwrite_original "-AllDates<Filename" "-FileCreateDate<Filename" "-FileModifyDate<Filename"  Y:\!temp\bbbb\img-20151204-wa0002.jpg
    1 image files updated

C:\>exiftool -time:all -G1 -a -s Y:\!temp\bbbb\img-20151204-wa0002.jpg
[System]        FileModifyDate                  : 2015:12:04 00:02:00-08:00
[System]        FileAccessDate                  : 2021:12:22 07:56:19-08:00
[System]        FileCreateDate                  : 2015:12:04 00:02:00-08:00
[IFD0]          ModifyDate                      : 2015:12:04 00:02:00
[ExifIFD]       DateTimeOriginal                : 2015:12:04 00:02:00
[ExifIFD]       CreateDate                      : 2015:12:04 00:02:00
* 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

That is odd.  Your FileCreateDate is behaving like StarGeek's FileAccessDate, and visa versa.

A couple of questions:

1. What version of ExifTool are you using?

2. What type of filesystem is the file on?

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

mak

Exiftool version is 12.3.8.0

Filesystem is NTFS

Phil Harvey

OK, thanks.  Nothing unusual there.  I can't explain what you are seeing.

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

jwilleke

I have several files in a folder where the filename starts with the date that I want the DateTimeOriginal to be.

Is there a method for the date from
2015-01-01-MtButler-540-5-1116.jpg
to become the DateTimeOriginal?

Thanks!

StarGeek

I'm assuming that none of the other numbers in the filename are the time?

The problem is that you need an actual time to complete the tag. Here's how you would write it using a time of midnight on that day
exiftool "-DateTimeOriginal<${Filename;m/(\d{4}-\d\d-\d\d)/;$_=$1;} 00:00:00" /path/to/files/
* 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).