ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: fkatzen on December 26, 2010, 07:44:32 PM

Title: How to set createdate tag using filename as source of date
Post by: fkatzen on December 26, 2010, 07:44:32 PM
My pictures don't have EXIF tags but the camera saved the files using filenames with the following format: mtdyyrhrmn.jpg. For example the file 0121071045.jpb was created jan 21 2007 at 10:45 am.
Can anyone provide command that allows writing the create date tag using filenames with the format above?
Thanks
Title: Re: How to set createdate tag using filename as source of date
Post by: Phil Harvey on December 27, 2010, 07:46:46 AM
This will require a specialized user-defined tag.  I can provide you with a configuration file to do this later in the day.

- Phil
Title: Re: How to set createdate tag using filename as source of date
Post by: Phil Harvey on December 27, 2010, 11:56:13 AM
Here is a thread (https://exiftool.org/forum/index.php/topic,2701.0.html) that describes the basic technique, and gives a config file which is close to what you need.  The only change you need to make is to use a value conversion something like this:

    ValueConv => q{
        return undef unless $val =~ /(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/;
        return(($3 lt '70' ? '20' : '19') . "$3:$1:$2 $4:$5:00");
    },


And a command like this:

exiftool "-createdate<mydatetime" FILE

- Phil