Extract just date/timestamp not field tag as well using exiftool in bash script

Started by akosprime, October 31, 2022, 09:08:00 AM

Previous topic - Next topic

akosprime

I've got a very basic understanding of the exiftool and can do simple command line executions like:

exiftool -modifydate [filename]

But the output includes the field tag, e.g.:

Modify Date:                    : 2022:10:17 06:12:12

I need to use this in a bash script. I cannot use a Perl script because I've been told to not rely on having access to anything that doesn't come with a 'vanilla Red Hat Linux install' although ironically requesting that the exiftool rpm be installed is ok. Honestly, I think there just might be a prejudice against Perl in house. Regardless, I have to develop the script as a bash shell script and invoke exiftool directly inside it.

So, without having to play games with awk/sed to process the output listed above, is there any way to invoke exiftool so that its output is only the date/timestamp and doesn't include the field tag?

The goal is to extract the create and/or modify dates from the metadata and then be able to compare them to a newly uploaded file of the same name to ensure that the newly uploaded file is in fact actually a newer revision and not simply a mistaken upload. This is done because if a file is a newer version, then a cpu and time intensive process is performed on the uploaded file and we wish to avoid this if someone just mistakenly uploads the same file, for example during a bulk upload. So, we need to store the date/time of each file and compare them - that's the ultimate goal here.

I tried searching on the forum, but there are so many threads with 'date' in them that finding this specifically seemed to get lost in the chaff.

Thanks in advance!

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

akosprime

Thanks so much! Sorry for missing that very easy option in the man page!