Old avi files with createdate inside the filename but no date/time tags set

Started by SimonM, August 15, 2011, 06:17:33 PM

Previous topic - Next topic

SimonM

Hi. I have a number of one line exiftool commands i use to manage photos and movies from my camera before i import into Adobe Elements.  Decided to add old camcorder avi files.  These avi files were created using a utility winDV that auto splits a digital camcorder tape into a series of files.  An example filename is ".10-10-23_17-25.00" so its .yy-mm-dd_hh-mm.ss

Command "exiftool -a -u -g1 DIR" shows these avi files have only one date tag - namely 'File Modification Date/Time'

So my problem is to somehow extract the date and time from within the filename and to insert this into the tag CreateDate or DateTimeOriginal.  Any assistance would be appreciated

Phil Harvey

Unfortunately, ExifTool does not yet support writing AVI files, so you can't use it to write CreateDate or DateTimeOriginal to these videos.  (although it will write the FileModifyDate because this is part of the filesystem, not the file itself)

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

SimonM

Hi Phil,
Adobe Elements uses the FileModifyDate for automatic chronological sorting. So part of my normal workflow is to 'exiftool "-FileModifyDate<CreateDate" -ext MOV DIR60D' - obviously this is for non avi files.

So my challenge is to use the filename to set FileModifyDate.  Is exiftool the right tool for this task?  I also have a file rename utility so I can easily change my filename, e.g. from '.10-10-23_17-25.00' to say '20101023_172500' if this simplifies the problem.

SimonM

Just been searching the forum again and doing a few tests and this works  'exiftool "-FileModifyDate<FileName" -ext AVI DIR'  it works.  The only thing I had to do to the filename was manually add 20 to make the year component 4 digits - hence the filename was '.2010-10-23_17-25.00' and this correctly sets FileModifyDate.  I will have a play to see how to auto append the '20'

Phil Harvey

I'm glad you discovered this.  This works because ExifTool is flexible about the input date/time formatting, but it does require a 4-digit year as you mentioned.  If it weren't for the dot at the start of the filename, you could do this:  "-filemodifydate<20$filename".  (note: use single quotes in Mac/Linux or double quotes like this in Windows)

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

rosell-dk

I just bumped into this.
I solved a similar problem by creating a CompositeTag in the config.
My code looks for Samsung naming scheme, though (ie: "20150827_165859.jpg") , but can easily be modified to fit your need
Here is the code:


        DateFromFilename => {
            Desire => {
              0 => 'OriginalFileName',
                1 => 'FileName',
            },

            Groups => { 2 => 'Time' },
            ValueConv => sub {
            $val = shift;

            foreach $filename (@$val) {
            # See if filename resembles date (it does on Samsung)
            # Samsung naming: "20150827_165859.jpg"
            if ($filename =~ /^\d{8}_\d{6}/) {
            $year = substr($filename, 0, 4);
            $month = substr($filename, 4, 2);
            $day = substr($filename, 6, 2);
            $hour = substr($filename, 9, 2);
            $minute = substr($filename, 11, 2);
            $second = substr($filename, 13, 2);
            $y = int($year);
            $mo = int($month);
            $d = int($day);
            $h = int($hour);
            $mi = int($minute);
            $s = int($second);
           
            #return '2015:08:27 16:58:59';
            #return @$val[0];
            if (
            (($y > 1900) && ($y < 2400)) &&
            (($mo >= 1) && ($mo <= 12)) &&
            (($d >= 1) && ($d <= 31)) &&
            (($h >= 0) && ($h <= 24)) &&
            (($mi >= 0) && ($mi <= 60)) &&
            (($s >= 0) && ($s <= 60))
            ) {
            # '2015:08:27 16:58:59';
            return $year . ':' . $month . ':' . $day . ' ' . $hour . ':' . $minute . ':' . $second;
            }
            }           
            }
            return undef;
            },           
            Shift => 'Time',
            Validate => 'ValidateExifDate($val)',
            PrintConv => '$self->ConvertDateTime($val)',
            #PrintConvInv => '$self->InverseDateTime($val,0)',
        },



Once you added the tag, you can run the following command to set the dates:
exiftool -r '-CreateDate<DateFromFilename' -if 'not CreateDate' .

The above command is gentle - it will only set CreateDate if it isn't already set, and if it can be passed from the filename

I btw store the original file name in OriginalFileName before I do any renaming, so that is why that tag is also checked. It doesn't hurt to leave it.

StarGeek

You really should check the dates and not ignore the red warning that pops up when you hit reply.  This is a 10 year old thread from a user that hasn't posted in 8 years.

Also, this config file isn't needed.  As per FAQ #5 in the paragraph that starts "Having said this...", all you need to do is copy the filename directly.  Exiftool can figure out the time stamp from a filename when it has all the numbers for YearMonthDayHourMinuteSecond.
exiftool -r '-CreateDate<Filename' -if 'not CreateDate' .
"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