Run command if createdate = 31/12/2019

Started by Spadez, February 05, 2020, 01:53:00 PM

Previous topic - Next topic

Spadez

Hello,

I have a lot of files that have the wrong createdate of 31/12/2019 and the real data is missing, but they are in folders with the correct date. However I only want to run my command on those files which have the wrong date.

The closest I could muster is this:

exiftool -filename -if "$createdate gt ${31/12/2019}" DIR

This doesn't work however. May I please ask what I should be putting in this case?

StarGeek

See FAQ #5 for how to format date and time stamps.

If you want to only process files that came on or after 2019:12:31, then try this if you're on Windows
exiftool -filename -if "$createdate gt '2019:12:31' " DIR
That will list the files.

Changing the time stamp might be a bit more complex, depending upon whether you want to keep the time part as is or don't care if it gets overwritten.  Also depending upon the format of the date in the directory.
"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

Spadez

#2
Thank you for this.

My files are in the folder directory named the day of the photo: 2019/01/20 for example. I want to rename files with createdate of 31/12/2019 with the name of the directory that file is in.

Therefore I think this is the command I need:

exiftool -if "$createdate gt ${31:12:2019}" '-datetimeoriginal<${directory} 00:00:00' -r -progress .

I have made a backup and ran it, but nothing happens, it looks like it might be running but after a few mins there are no updates. Are you able to perhaps help me understand what is going wrong?

StarGeek

First of all, you're mixing tags.  CreateDate and DateTimeOriginal are two different tags, though they probably should have the same time stamp.  You shouldn't check one tag and then write to another tag.  You can write to AllDates if you want to correct both tags.  You should double check though, try running this command on a file
exiftool -time:all -g1 -a -s <FileOrDir>

You did not read FAQ #5 as I mentioned.  Your date is incorrectly formatted.  Take a look at the command I posted.

Copying from the directory will only work if there are no other numbers in the directory path.

You can add the -progress option to the command to have it list what files it is updating as it is running.
"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

Spadez

#4
Thank you for the help and sorry for the mix up on dates. I think I'm having a bit of a hard time with this. I'm on a Mac with the latest version.

Example directory:
2011/07/15

myimage.jpg inside above directory:
FileModifyDate : 2019:12:31 22:44:44+00:00

Required Result:
If FileModifyDate of 2019/12/31
Take directory and set it to FileModifyDate
FileModifyDate: 2011:07:15 00:00:00+00:00

My Command:
exiftool -if "$FileModifyDate gt '2019:12:31' " '-AllDates<${directory} 00:00:00' -progress -r .

Outcome:
No changes.
2468 directories scanned
29306 files failed condition
0 image files read

StarGeek

On a mac you need to swap single/double quotes from my example.

exiftool -if '$FileModifyDate gt "2019:12:31" ' '-AllDates<${directory} 00:00:00' -progress -r .

Also, again you're checking one time stamp and setting a different one.  It's something you should be very sure it's what you want to do.  Setting AllDates will set the three most common EXIF time tags, CreateDate, DateTimeOriginal, and ModifyDate.  Also, the FileModifyDate tag will be set to the current date/time if it edits a file, which might mess up future runs if you make a mistake.  Add the -P (preserve) option to prevent that.
"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

Spadez

I'm sorry but I'm still having issues getting this working. I'll write out exactly what I am trying:

Folder Structure:
Test/2008-04-17/myfile.jpg

myfile.jpg
Create and modify date originally as 2019-12-31

Command (run inside Test Directory)
exiftool '-AllDates<${directory} 00:00:00' -progress -r -P .

Output
======== ./2008-04-17/myfile.JPG [1/1]
    2 directories scanned
    1 image files updated

Actual Outcome
File still has the same create and modify date of 2019-12-31

Intended Outcome
File has create and modify date of 2008-04-17

Full Output
---- System ----
FileModifyDate                  : 2019:12:31 22:44:44+00:00
FileAccessDate                  : 2020:02:02 15:59:28+00:00
FileInodeChangeDate             : 2020:02:07 18:21:09+00:00
======== ./2008-04-17/metadata.json
---- System ----
FileModifyDate                  : 2020:02:01 21:50:09+00:00
FileAccessDate                  : 2020:02:02 15:59:28+00:00
FileInodeChangeDate             : 2020:02:07 18:21:09+00:00
======== ./2008-04-17/5132E0F8-758A-4AA2-909B-B95E83CB9373.JPG
---- System ----
FileModifyDate                  : 2020:02:07 18:22:17+00:00
FileAccessDate                  : 2020:02:07 18:27:40+00:00
FileInodeChangeDate             : 2020:02:07 18:27:39+00:00
---- IFD0 ----
ModifyDate                      : 2008:04:17 00:00:00
---- ExifIFD ----
DateTimeOriginal                : 2008:04:17 00:00:00
CreateDate                      : 2008:04:17 00:00:00

Therefore it has set the ExifID but not the system information. Is there a way to set that too?

StarGeek

Add
'-FileModifyDate<${directory} 00:00:00'
to set the FileModifyDate.

The FileInodeChangeDate is listed that it can't be modified by exiftool, so a Mac/Linux user will have to weigh in on that.
"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

Phil Harvey

FileInodeChangeDate is the last time the filesystem directory information was changed for the file.  I don't know how to set 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 ($).