ExifTool Forum

ExifTool => Newbies => Topic started by: aage on April 07, 2014, 03:43:04 PM

Title: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 07, 2014, 03:43:04 PM
Hi

I have for a very long time searched for a way to rename all my digital photos and suddenly I found ExifTool that after 5 days of intensive reading seems to be the only tool that can solve my problem  :) :)

I would like to rename to this format : "Date_that_photo_was_taken"_"Capital_Letter_for_Daughter_Name"_"Daughter_Age"_"Capital_Letter_for_Son_Name"_"Son_Age".

That means that all photos should be named like this: 23052011_L3Y2M_J1Y4M.jpg
(Photo was taken 23.05.2011 and at that time my daughter was 3 years and 2 months old, her name starts with an L and my son was 1 year and 4 month old and his name starts with a J).

The above is only an example showing the format.

I would like to be able to write a few lines of code in the Terminal window on my MAC and put in both kids date of birth.

I have read this question :https://exiftool.org/forum/index.php/topic,3176.0.html and I accept that the calculation is based on 30 days a month  :)

This article is VERY close to what I would like but I don´t want to be dependent on the "name-idintifying-thing" in the config-file. Contrary I would like ALL photo to be renamed as described above and if one of the kids were not born on the date the photo was taken I would like to state that in the filename this way: 23052011_L3Y2M_JnotBorn.jpg

I think the calculation should be based on EXIF-field: datetimeoriginal.

I have now tried writing the line of code for the Terminal-window for several days (I am not a programmer) but I cant´t get it to work  :-\

Can somebody help me out - I would really appreciate it !!

Thanks  ;D
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 07, 2014, 07:08:31 PM
This sounds very do-able, but will require a custom config file containing a little trickery.  I'll come up with the config file for you.  I'll try to have a go at it tonight, but it may be tomorrow before I get a chance to work on this.

I just want to be sure I understand.  It doesn't matter who is in the photo.  The only variable input to the name of the file is DateTimeOriginal.  (The kid's names and birthdays are constants.)  Right?

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 08, 2014, 12:44:50 AM
Hi Phil

I really appreciate you helping me out - thanks a LOT !!!!!!

You wrote:
"I just want to be sure I understand.  It doesn't matter who is in the photo.  The only variable input to the name of the file is DateTimeOriginal.  (The kid's names and birthdays are constants.)  Right?"

Yes - that is all correct ;-)

Once again - Thanks in advance !

-Aage
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 08, 2014, 12:48:12 AM
Just forgot...
- is it possible to have the mark of the camera in front  - like : Canon_23052011_L3Y2M_J1Y4M.jpg ?

-Aage
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 08, 2014, 07:40:44 AM
Hi Aage,

Here you go.  Attached is a config file that should do what you want.  All you need to do is change the birthdays to the proper dates in the calls to MakeCode().  The command would look like this:

exiftool -config Aage.config "-filename<myfilename" DIR

where DIR is the name of the directory containing the images.

Here is what the config file looks like:

sub MakeCode($$$)
{
    my @date1 = split /[: ]/, shift;
    my @date2 = split /[: ]/, shift;
    my $name = shift;
    my $years = $date1[0] - $date2[0];
    my $months = $date1[1] - $date2[1];
    my $days = $date1[2] - $date2[2];
    if ($days < 0) { --$months; }
    if ($months < 0) { $months += 12; --$years; }
    my $str = '';
    $str .= "${years}Y" if $years > 0;
    $str .= "${months}M" if $months > 0 and $years >= 0;
    $str = "_$name$str" if $str;
    return $str;
}

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyFileName => {
            Require => {
                0 => 'DateTimeOriginal',
                1 => 'Make',
            },
            ValueConv => sub {
                my $vals = shift;
                my $date = $$vals[0];
                my $make = $$vals[1];
                my $daughter = MakeCode($date, '1998:03:22', 'L');
                my $son = MakeCode($date, '2003:10:13', 'J');
                $make =~ tr(/\\?*:|"<>\0)()d; # remove illegal characters
                my @parts = split /[: ]/, $date;
                return "${make}_$parts[2]$parts[1]$parts[0]$daughter$son";
            },
        },
    },
);
1;  #end


- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 08, 2014, 01:05:47 PM
Hi Phil

Thank you so much !!!

For activating the config-file I have read this one : https://exiftool.org/config.html
I am a bit unsure if I should rename the config-file as described - my guess is, that I should not. My guess is based on the command-line that you instruct me to write in the Terminal-window. Is that correct ?

My very limited knowledge of the MAC-filesystem makes me unsure where to place the config-file. Should this be in the Application-folder or somewhere in the Usr/bin-thing ? I have tried opening this directory but don´t know where to look - there is so many files and folders in there  :-X I have read the uninstalling description for Exif-tool and it states that you should know what you are doing before exetuting anything in here. I don´t know what I am dooing  :)

Can you guide me before I kill my MAC ;-)

/Lars 
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 08, 2014, 01:20:06 PM
Hi Lars,

There are 2 ways to activate the config file.  Either use the -config option as I have done, or rename the file and place it in a standard location (preferably your home directory) as per the config.html instructions.

For file/folder names on the command line, it may be easier for you to drag and drop the file/folder rather than typing the name -- then you don't need to worry about what folder it is in.

Also, I suggest trying this on a few test files before letting it loose on your pictures folder.

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 08, 2014, 02:37:48 PM
Hi Phil

You are fast !!

I will perform test before renaming all files ;-)

Here is what I did:
1) Placed the config-file in my HOME-directery
2) In Terminal-window: exiftool -config Aage.config "-filename<myfilename" /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

Result:
   1 directories scanned
    4 image files updated
   18 files weren't updated due to errors

4 files were renamed BUT changed to a file without extention (.jpg). I get this errormessage trying to open the file:
--------------------------------------------------------------
Last login: Tue Apr  8 20:59:00 on ttys001
Aagesens-Mac-mini:~ Aagesen$ /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_22072013_L15Y4M_J9Y9M ; exit;
-bash: /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_22072013_L15Y4M_J9Y9M: cannot execute binary file
logout
---------------------------------------------------------------
I also get a lot of warnings like:
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_2013_07_23_101444.JPG

I have read about these warnings but I can´t figure out how to fix it. Tried before you wrote me the script and config-file - but no luck  :-[

Quistions:
Q1) What to do about the warnings ?
Q2) How do I open the config-file for editing the birth of dates?
Q3) Can it run all sub-directories by adding the "-r"-thing and how would the command-line look with this added ?
Q4) Have I dione something wrog since renamed files are changed and without extention ?
Q5) Does the script work for .MOV and other video-files as well? (Think I have read a post somewhere that a command-line preference can make this happen ?)

/Lars
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 09, 2014, 07:44:04 AM
Hi Lars,

Quote from: aage on April 08, 2014, 02:37:48 PM
4 files were renamed BUT changed to a file without extention (.jpg).

Ooops, sorry.  I should have used "-filename<$myfilename.%e"

QuoteI also get a lot of warnings like:
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_2013_07_23_101444.JPG

The lower-case "m" minor warnings are informational only, and ExifTool will fix this particular problem automatically.

QuoteQ2) How do I open the config-file for editing the birth of dates?

With any plain text editor.

QuoteQ3) Can it run all sub-directories by adding the "-r"-thing and how would the command-line look with this added ?

Yes.  Just add -r anywhere on the command line, separated from other arguments by spaces.

QuoteQ5) Does the script work for .MOV and other video-files as well?

It works for any writable type.  MOV is now a writable type.  See FAQ 16 (https://exiftool.org/faq.html#Q16) for more information.

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 09, 2014, 03:01:43 PM
Hi Phil

Thanks again for getting back to me on this one ;-)

Just tried this command: exiftool -config Aage.config "-r -filename<myfilename.%e" /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

I now get this result (minor warnings and Warnings):
----------------------------------------------------------------
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/013_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/013_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1255.MOV
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1981.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1982.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1983.JPG
    1 directories scanned
    0 image files updated
   17 image files unchanged
----------------------------------------------------------------

Camera used making .JPG and .MOV are : Canon Ixus, Canon EOS 450, Canon EOS 600, Iphone 3 +4

What do I do wrong ?

/Lars
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 10, 2014, 07:26:32 AM
Hi Lars,

The -r must be outside the quotation marks, otherwise it becomes part of the -filename argument.

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Oskar on April 10, 2014, 08:24:54 AM
Also, Totalcommander has a powerful rename tool. Select files, press Ctrl+M and you get a dialog with lots of options: date, custom text, extension etc.
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 10, 2014, 09:02:57 AM
Quote from: Oskar on April 10, 2014, 08:24:54 AM
Totalcommander has a powerful rename tool. Select files, press Ctrl+M and you get a dialog with lots of options: date, custom text, extension etc.

...but will it calculate the age of Lars' children?  I suspect not.

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 10, 2014, 11:39:42 AM
Hi Oskar and Phil

Exactly as Phil mentioned - no other renameing-tool that I have come across can calculate the age of my kids. ExitTool is the far most flexible tool that I have ever seen - and with Phil on the side - you can´t wish for more ;-)

I tried this command :xiftool -config Aage.config -r "-filename<myfilename.%e" /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

The result is better than placing the "-r" in front of the "-config" - I tried that as well ;-)

Nevertheless the result of the command above is this:
---------------------------------------------------------------------------------------------------------------------------------------------------
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/009_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/009_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/IMG_1254.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/IMG_1257.MOV
    3 directories scanned
    0 image files updated
   25 image files unchanged
---------------------------------------------------------------------------------------------------------------------------------------------------

Do you think my pictures and videos are corrupt in some way since no renaming is done ?

/Lars
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 10, 2014, 11:43:32 AM
Hi Lars,

For the command to function, the MyFileName tag must exist.  For this to exist, the config file must be working and the DateTimeOriginal and Make tags must exist.  What is the output of this command?:

exiftool -config Aage.config -datetimeoriginal -make -myfilename /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 10, 2014, 12:45:56 PM
Hi Phil

Here is the output:
-------------------------
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/001_21_07_2013.JPG
Date/Time Original              : 2013:07:21 22:27:46
Make                            : Canon
My File Name                    : Canon_21072013_L5Y11M_J3Y2M
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/002_22_07_2013.JPG
Date/Time Original              : 2013:07:22 19:10:32
Make                            : Canon
My File Name                    : Canon_22072013_L5Y11M_J3Y2M
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/003_22_07_2013.JPG
Date/Time Original              : 2013:07:22 19:11:16
Make                            : Canon
My File Name                    : Canon_22072013_L5Y11M_J3Y2M
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/004_22_07_2013.JPG
Date/Time Original              : 2013:07:22 19:11:39
Make                            : Canon
My File Name                    : Canon_22072013_L5Y11M_J3Y2M
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/005_23_07_2013.JPG
Date/Time Original              : 2013:07:23 09:20:45
Make                            : Canon
My File Name                    : Canon_23072013_L5Y11M_J3Y2M
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/006_23_07_2013.JPG
Date/Time Original              : 2013:07:23 09:47:08
Make                            : Canon
My File Name                    : Canon_23072013_L5Y11M_J3Y2M
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/007_23_07_2013.JPG
Date/Time Original              : 2013:07:23 09:50:00
Make                            : Canon
My File Name                    : Canon_23072013_L5Y11M_J3Y2M
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/008_23_07_2013.JPG
Date/Time Original              : 2013:07:23 10:04:21
Make                            : Canon
My File Name                    : Canon_23072013_L5Y11M_J3Y2M
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/009_23_07_2013.JPG
Date/Time Original              : 2013:07:23 10:14:44
Make                            : Canon
My File Name                    : Canon_23072013_L5Y11M_J3Y2M
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/010_23_07_2013.JPG
Date/Time Original              : 2013:07:23 10:34:53
Make                            : Canon
My File Name                    : Canon_23072013_L5Y11M_J3Y2M
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/011_23_07_2013.JPG
Date/Time Original              : 2013:07:23 10:38:00
Make                            : Canon
My File Name                    : Canon_23072013_L5Y11M_J3Y2M
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/012_23_07_2013.JPG
Date/Time Original              : 2013:07:23 18:37:07
Make                            : Canon
My File Name                    : Canon_23072013_L5Y11M_J3Y2M
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/013_23_07_2013.JPG
Date/Time Original              : 2013:07:23 20:22:21
Make                            : Canon
My File Name                    : Canon_23072013_L5Y11M_J3Y2M
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1255.MOV
Make                            : Apple
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1981.JPG
Date/Time Original              : 2004:08:14 12:23:32
Make                            : Canon
My File Name                    : Canon_14082004
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1982.JPG
Date/Time Original              : 2004:08:14 12:24:43
Make                            : Canon
My File Name                    : Canon_14082004
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1983.JPG
Date/Time Original              : 2004:08:14 12:24:59
Make                            : Canon
My File Name                    : Canon_14082004
    1 directories scanned
   17 image files read
-------------------------
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 10, 2014, 12:52:50 PM
Oops, you forgot the "$", and I didn't catch it.  Try this:

exiftool -config Aage.config -r "-filename<$myfilename.%e" /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 10, 2014, 01:13:31 PM
My Terminalwindow:
-----------------------------
exiftool -config Aage.config -r "-filename<$myfilename.%e" /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/001_21_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/001_21_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/002_22_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/002_22_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/003_22_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/003_22_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/004_22_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/004_22_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/005_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/005_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/006_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/006_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/007_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/007_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/008_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/008_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/009_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/009_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/010_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/010_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/011_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/011_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/012_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/012_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/013_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/013_23_07_2013.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1255.MOV
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1981.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1982.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1983.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe1/IMG_1256.MOV
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe1/IMG_1978.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe1/IMG_1979.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe1/IMG_1980.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/IMG_1251.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/IMG_1253.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/IMG_1254.JPG
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/IMG_1257.MOV
    3 directories scanned
    0 image files updated
   25 image files unchanged
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 10, 2014, 01:19:50 PM
Now this one is my fault.  I forgot you are on a Mac.  On Mac you need to use single quotes around arguments with a '$':

exiftool -config Aage.config -r '-filename<$myfilename.%e' /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

Sorry about that.  It really shouldn't be this difficult to get things working.

I dont' know why you didn't see this message, which I get on my Mac if I do it wrong:

    myfilename: Undefined variable.

because the Terminal shell fails when it tries to interpret "$myfilename" as a shell variable within the double-quoted string.

- Phil

Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 10, 2014, 01:30:32 PM
Thanks - i'll try it when my kids is a sleep - please sleep, kids ;-)

I'll get back ;-)

/Lars
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 10, 2014, 02:46:07 PM
Hi Phil

Now things seems to be much better - thank you !

Here is my Terminal-window - still with some errors that causes some files not to be renamed. I think I have a guess - please see after Terminal-window-log:
-----------------------------------Aagesens-Mac-mini:~ Aagesen$ exiftool -config Aage.config -r '-filename<$myfilename.%e' /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/001_21_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/002_22_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/003_22_07_2013.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_22072013_L5Y11M_J3Y2M.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/003_22_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/004_22_07_2013.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_22072013_L5Y11M_J3Y2M.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/004_22_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/005_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/006_23_07_2013.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_23072013_L5Y11M_J3Y2M.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/006_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/007_23_07_2013.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_23072013_L5Y11M_J3Y2M.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/007_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/008_23_07_2013.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_23072013_L5Y11M_J3Y2M.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/008_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/009_23_07_2013.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_23072013_L5Y11M_J3Y2M.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/009_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/010_23_07_2013.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_23072013_L5Y11M_J3Y2M.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/010_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/011_23_07_2013.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_23072013_L5Y11M_J3Y2M.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/011_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/012_23_07_2013.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_23072013_L5Y11M_J3Y2M.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/012_23_07_2013.JPG
Warning: [minor] Adjusted MakerNotes base by 4038 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/013_23_07_2013.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_23072013_L5Y11M_J3Y2M.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/013_23_07_2013.JPG
Warning: [minor] Tag 'myfilename' not defined - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1255.MOV
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1255.MOV
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_14082004.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1982.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Canon_14082004.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/IMG_1983.JPG
Warning: [minor] Tag 'myfilename' not defined - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe1/IMG_1256.MOV
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe1/IMG_1256.MOV
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe1/Canon_14082004.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe1/IMG_1979.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe1/Canon_14082004.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe1/IMG_1980.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/Apple_27042012_L4Y9M_J2Y.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/IMG_1253.JPG
Error: '/Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/Apple_27042012_L4Y9M_J2Y.JPG' already exists - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/IMG_1254.JPG
Warning: [minor] Tag 'myfilename' not defined - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/IMG_1257.MOV
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/IMG_1257.MOV
    3 directories scanned
    6 image files updated
    3 image files unchanged
   16 files weren't updated due to errors
-----------------------------------------------------------

My guess is that existing name of file (eksample: 003_22_07_2013.jpg -> 013_22_07_2013.jpg) are the same as far as ExifTool config-file is designed with parameters. Maybe the solution is to add HH.MM.SS to the config-file to distinguish files from the same day from each other. The the new filename should be in this format: Canon_22_07_2013_143025_L5Y11M_J3Y2M.jpg. This format will then "replace" my own existing format starting with leading zero - like 001, 002,003 etc.

What do you think and can you help me implement that in the config-file. (I have tried to figure it out myself - but must admit that I don´t have a clue ;-)

Is there another way ?

A few JPG´s are only renamed with mark and date but not the agecalculation and all MOV-files are not renamed. Could that be caused by missing the metadata so Exiftool can´t calculate ?

/Lars
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 10, 2014, 08:43:45 PM
Hi Lars,

Adding the time won't necessarily solve the problem (2 images can be taken in the same second).  So if the time isn't useful information I would suggest just adding a serial number, which you can do like this:

'-filename<$myfilename%-c.%e'

See the -w description in the application documentation for details about formatting the %c number to suit your tastes.

Try using CreateDate instead of DateTimeOriginal for the MOV files (this should also work for the JPG's).  Also, you should check to be sure they have Make information.

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 11, 2014, 06:23:42 PM
Hi Phil

You are rigth - again ;-)

I have now made a second config-file using the "CreateDate" and added a copynumber to the filename. My command line now looks like this:

exiftool -config Aage2.config -r '-filename<$myfilename%+.4nc.%e' /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

...and it does exactly what I want to all my JPG´s and my MOV´s. I am so happy !!!!!!

A final quistion ;-)

I have some .MOD-files from a JVC videocamera and some .avi-files. These files are not renamed at all.

I have read posts in the forum about the "-ext avi" and then tried this using both DateTimeOriginal and CreateDate:
--------------------------------------------------------------------------------------
exiftool -config Aage.config -r -ext avi '-filename<$myfilename%+.4nc.%e' /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe
Warning: [minor] Tag 'myfilename' not defined - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/Blandet 028.avi
Warning: No writable tags set from /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/Undermappe2/Blandet 028.avi
    3 directories scanned
    0 image files updated
    1 image files unchanged
--------------------------------------------------------------------------------------

Still no success renaming these files and maybe this is caused (for the. MOD-files) by the fact that the documentation does not say anything about .MOD-files. It does however says that .MODD-files are supported - but I guess that this is some other file-format.

If ExifTool can´t solve this - actually I will just do it by hand - because using ExifTool on all other files in my directory have saved me a lot of time that I can spent on manually renaming these last files-types ;-)

/Lars
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 11, 2014, 07:12:48 PM
Again, these files must contain the Require'd tags from your config file for MyFileName to be generated.

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 14, 2014, 01:24:54 PM
Hi Phil

Thanks - I have been reading a bit and tried this - but with no luck.

Terminal-window: exiftool -a -u -g1 /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST/002_20_07_2007.MOD
Result in this info:
-----------------------------------------------------------------------------
---- ExifTool ----
ExifTool Version Number         : 9.55
---- System ----
File Name                       : 002_20_07_2007.MOD
Directory                       : /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST
File Size                       : 85 MB
File Modification Date/Time     : 2007:07:20 19:57:50+02:00
File Access Date/Time           : 2014:04:14 18:53:35+02:00
File Inode Change Date/Time     : 2014:04:14 18:53:42+02:00
File Permissions                : rwxr-xr-x
---- File ----
File Type                       : MPEG
MIME Type                       : video/mpeg
---- MPEG ----
Image Width                     : 720
Image Height                    : 576
Aspect Ratio                    : 0.6735
Frame Rate                      : 25 fps
Video Bitrate                   : 8.4 Mbps
---- Composite ----
Duration                        : 0:01:24 (approx)
Image Size                      : 720x576
-----------------------------------------------------------------------------

Note that "File Modification Date/Time" is the date that MOD-file was created.

My idear was to copy this date into "CreateDate" which my config-file can process with the result of calculating the age of my kids and rename the file.

BUT running this in Terminal-window: exiftool "-filemodifydate<createdate" /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST gives me this result:
------------------------------------------------------------------------------
    1 directories scanned
    0 image files read
------------------------------------------------------------------------------

I have noticed that running this one : exiftool -a -u -g1 /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST trying to read out all metadata from DIR also result in the above "0 image files read".

What am I missing - and do you think I am on the right track here ?

/Lars
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 14, 2014, 07:35:57 PM
Hi Lars,

We could use FileModifyDate if the other date/time tags aren't available.  I could build this into the config file, but I don't have the time right now.  Give me until tomorrow morning and I'll come up with something for you.

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 15, 2014, 01:37:07 AM
Phil, that would be awesome :)
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 15, 2014, 07:14:01 AM
Attached is a config file that will generate MyFileName for any source file.  It uses DateTimeOriginal, or CreateDate if DateTimeOriginal isn't available, or FileModifyDate if neither is available.  And it puts the Make at the start of the name only if it is available.

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 15, 2014, 11:38:40 AM
Hi Phil

Thanks - just tested the new config-file, which I have named Aage3.config. Unfortunately only still JPG´s are renamed.

In my directory "MOD_filer_TEST" I have the following files:
--------------------------------------------------------
002_20_07_2007.MOD
004_20_07_2007.MOD
Blandet_28.avi
Canon_06122012_L13Y9M_J8Y2M_0001.JPG
Canon_06122012_L13Y9M_J8Y2M_0002.JPG
Canon_26122011_L13Y9M_J8Y2M_0001.JPG
Canon_26122011_L13Y9M_J8Y2M_0002.JPG
Canon_26122011_L13Y9M_J8Y2M_0003.JPG
--------------------------------------------------------

As you can se only the JPG´s are renamed after running this :
exiftool -config Aage3.config -r '-filename<$myfilename%+.4nc.%e' /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST

The result is this:
-------------------------------------------------------------
Warning: [minor] Adjusted MakerNotes base by 4160 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST/Canon_06012012_L13Y9M_J8Y2M_0001.JPG
Warning: [minor] Adjusted MakerNotes base by 4160 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST/Canon_06012012_L13Y9M_J8Y2M_0002.JPG
Warning: [minor] Adjusted MakerNotes base by 4160 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST/Canon_26122011_L13Y9M_J8Y2M_0001.JPG
Warning: [minor] Adjusted MakerNotes base by 4160 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST/Canon_26122011_L13Y9M_J8Y2M_0002.JPG
Warning: [minor] Adjusted MakerNotes base by 4160 - /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST/Canon_26122011_L13Y9M_J8Y2M_0003.JPG
    1 directories scanned
    0 image files updated
    5 image files unchanged
-------------------------------------------------------------

I tried to change the extention of one MOD-file from MOD to MPEG - but still no renaming was done.

It looks like ExifTool dosen´t even know that the MOD´s and AVI´s are there.

What do think ?

And Phil, if this is getting to complicated and takes up all your spare time - please tell me ! Then I will do it by hand or accept that I have choosen the wrong Video Camera ;-) But a few more "rounds of trying" would save me manually renaming more than 3.000 MOD´s documenting the life of my two kids ;-)
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 15, 2014, 11:49:23 AM
Lars,

First, see FAQ 16 (https://exiftool.org/faq.html#Q16) for why the AVI and MOD files weren't touched.

For the JPEG files, you need to give me more information.  What is the output from this command?:

exiftool -config Aage3.config -myfilename -make -datetimeoriginal -createdate -filemodifydate /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 15, 2014, 12:16:10 PM
Hi Phil

I´ll read FAQ 16 and here is the output of this one:
exiftool -config Aage3.config -myfilename -make -datetimeoriginal -createdate -filemodifydate /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST

Output:
-----------
Aagesens-Mac-mini:~ Aagesen$ exiftool -config Aage3.config -myfilename -make -datetimeoriginal -createdate -filemodifydate /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST/004_20_07_2007.MPEG
My File Name                    : 20072007_L9Y3M_J3Y9M
File Modification Date/Time     : 2007:07:20 21:26:52+02:00
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST/Blandet 028.avi
My File Name                    : 03052008_L10Y1M_J4Y6M
Date/Time Original              : 2008:05:03 14:53:30
File Modification Date/Time     : 2008:05:19 21:28:06+02:00
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST/Canon_06012012_L13Y9M_J8Y2M_0001.JPG
My File Name                    : Canon_06012012_L13Y9M_J8Y2M
Make                            : Canon
Date/Time Original              : 2012:01:06 18:37:09
Create Date                     : 2012:01:06 18:37:09
File Modification Date/Time     : 2012:01:06 18:37:10+01:00
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST/Canon_06012012_L13Y9M_J8Y2M_0002.JPG
My File Name                    : Canon_06012012_L13Y9M_J8Y2M
Make                            : Canon
Date/Time Original              : 2012:01:06 18:37:01
Create Date                     : 2012:01:06 18:37:01
File Modification Date/Time     : 2012:01:06 18:37:02+01:00
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST/Canon_26122011_L13Y9M_J8Y2M_0001.JPG
My File Name                    : Canon_26122011_L13Y9M_J8Y2M
Make                            : Canon
Date/Time Original              : 2011:12:26 11:16:01
Create Date                     : 2011:12:26 11:16:01
File Modification Date/Time     : 2011:12:26 11:16:02+01:00
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST/Canon_26122011_L13Y9M_J8Y2M_0002.JPG
My File Name                    : Canon_26122011_L13Y9M_J8Y2M
Make                            : Canon
Date/Time Original              : 2011:12:26 11:15:45
Create Date                     : 2011:12:26 11:15:45
File Modification Date/Time     : 2011:12:26 11:15:46+01:00
======== /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe/MOD_filer_TEST/Canon_26122011_L13Y9M_J8Y2M_0003.JPG
My File Name                    : Canon_26122011_L13Y9M_J8Y2M
Make                            : Canon
Date/Time Original              : 2011:12:26 11:15:41
Create Date                     : 2011:12:26 11:15:41
File Modification Date/Time     : 2011:12:26 11:15:42+01:00
    1 directories scanned

/Lars
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 15, 2014, 12:49:38 PM
Hmmm.  So MyFileName is available for all the files.  This means that the config file is working as designed.  I don't understand why the renaming command didn't work.

Oh, wait.  It didn't work because the files already had the desired name.

Doh.

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 15, 2014, 01:14:46 PM
Hi again

The renaming didn`t work even though "MyFileName" is available for almost all files.
The MPEG and the AVI files are not renamed (the AVI properly because of FAQ 16).
The MPEG file is actually just a MOD-file where I changed the extention from MOD to MPEG. The result of this is that ExifTool can see the file in DIR but not do the renaming. In the DIR the file is still named "004_20_07_2007.MPEG" and not"20072007_L9Y3M_J3Y9M.MPEG" as ExifTool normally would do.

There are 8 files in the DIR but only 7 files gave output. The last file in the DIR was a MOD-file (same as the MPEG-file but no change from original MOD extention  to MPEG as the above mentioned file.

Very strange. Could the MOD/MPEG files in some way be "read only" ?
/Lars
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 15, 2014, 08:49:00 PM
Hi Lars,

Quote from: aage on April 15, 2014, 01:14:46 PM
The MPEG and the AVI files are not renamed (the AVI properly because of FAQ 16).

Re-read the first sentence of FAQ 16.  It applies not only to AVI files.

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on April 17, 2014, 03:36:25 PM
Hi Phil

I have read FAQ 16 once again and wrote this :

exiftool -config Aage3.config -ext MOD -ext JPG –ext AVI -ext avi -ext MPG -r '-filename<$myfilename%+.4nc.%e' /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

This one does exactly what I want - and it does so to all files in my DIR ;-)

I will now do a final test - but I am convinced that the new config-file and the above command are ready for doing the real job to all my files.

Phil, once again - Thank you so much for helping me out with this. I have told everybody who cared to listen about ExifTool and the help that you have provided ;-)

Happy easter !!

/Lars

P.S. ExifTool is now added to my Favorites and I have already started to read some posts about moving old DIR-names to keywords ;-)
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on April 17, 2014, 04:29:22 PM
Hi Lars,

Great!  Glad everything is working for you now...  just in time for the holiday.

Have a happy Easter too.

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on July 08, 2014, 01:53:54 PM
Hi Phil

Here we go again ;-)

Some months ago you helped me creating a configfile that calculated the age of my two children for adding this in the filename. Once again , thanks a lot for this! The configfile is attatched.

I have now worked a lot with my pictures and finally found a way that I want them to be categorized – for general organization and for thye use in Picasa.

Part of collection1:
A lot of pictures are placed in folders/subfolders where foldename/path explains the content – like "Party/Birthdays/Mom". The files are all renamed like this : Party_Birthdays_Mom_14_07_2014.jpg

Part of collection2:
Another part of my collection is placed in folders where foldername states the date that I have copied the pictures to my computer.

After working with organization and studying the way Picasa works I have the following needs for organizing my entire collection:
1)   All IPTC-tags must be deleted from all pictures.
2)   All pictures in "Part of collection 2" must be moved into folders representing Year and Month and files renamed in accordance with the new folder structure and added the files CAPTIONdate + a following number like 001/002 etc. (is this the way to proceed : https://exiftool.org/forum/index.php/topic,4409.0.html)
3)   All pictures in entire collection must have IPTC tags added for each folder and subfolder. This means that picture "Party_Birthdays_Mom_14_07_2014.jpg" must have the following IPTC tags : Party, Birthdays, Mom
4)   All pictures in entire collection must have daughter and son´s age (as calculated in configfile) added as IPTC-tag.

My question is:
1)   Can you guide me how to accomplish this – and do you think that the steps above is right (and I right order) for doing this job ?
2)   When you helped me the last time I found threads in the forum explaining how to fix step 3 – but I can´t seem to find them anymore. Can you help?
3)   Can you help me re-write the configfile attatched so it can do the job in step 4?

I think organizing pictures is quite a difficult job to do, because you have to think in general terms of use and for use in special software (Picasa). I hope that placing the meta-data in IPTC section will work for the years to come. Any comment on that – do you think I have chosen the right section compared to EXIF or any of the other standards?
Please help me out so that I can get my "beauty-sleep" back again ;-)
Kind regards
Aage
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on July 08, 2014, 04:19:47 PM
Hi Aage,

I'm away from home this week and don't have a lot of time to help, so I won't be able to give you detailed advice for a while.

About the IPTC:  What ExifTool calls IPTC is the original IPTC IIM format, which is slowly becoming obsolete in favour of the new XMP standard.  IPTC has even come up with a new specification which uses the XMP format.  So I would suggest using XMP instead of IPTC if it is compatible with your needs in Picasa.

One trick that might help you is that you can split a list-type tag into separate items easily when writing.  So this command:

exiftool '-subject<${filename;s/_\d+_\d+_\d+\..*//}' -sep "_" -r DIR

will take file names like "Party_Birthdays_Mom_14_07_2014.jpg" and split them into separate Subject items "Party", "Birthdays" and "Mom".  (XMP Subject is the replacement for IPTC Keywords, btw.)  This does part of what you wanted in one of your steps I think.  Here I used an advanced formatting expression to first trim the date and extension from FileName, but you could have just as easily created a user-defined Composite tag to do this instead.

(Note to other readers: The above quoting is for Mac/Linux.  Use double quotes instead in Windows.)

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on July 09, 2014, 02:10:33 PM
Hi Phil (and others)

No worries ;-)

I´ll try to solve this step-by-step and I have started with the "move-files-to-new-directory-step" ;-)

exiftool 'directory</Users/Aagesen/ExifTool_ExportFile/All_New_Files_Sorted_By_Year/$datetimeoriginal/' -d "%Y/%m" -r  /Users/Aagesen/ExifTool_ExportFile/All_Unsorted_Files

The above command does exactly what I want but does not move .MOV and .avi-files.

The configfile "Aage3.config" however is launched by this one and therefor (i guess) also renames those mentioned files:

exiftool -config Aage3.config -ext MOD -ext JPG –ext AVI -ext avi -ext MPG -r '-filename<$myfilename%+.4nc.%e' /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

I have tried to apply the same "-ext MOD"-kind-of-syntax but it dosen´t work.

Please help me out whenever you have the time - I will wait and just appriciate your involvement whenever you have the time !

/Aage
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on July 09, 2014, 05:19:30 PM
Hi Aage,

If you add -ext mov -ext avi to your original command, it should process only MOV and AVI files.  (The case of the -ext argument is not significant.)  I am surprised you say that this didn't work for you.  It should.

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on July 10, 2014, 01:33:24 AM
Hi Phil

All unsorted files is inside : 02_Video_Kamera_tømt_25122009
All unsorted files are name like this : 018_25_07_2009.MOD

I ran : exiftool -t  02_Video_Kamera_tømt_25122009 > out.txt
out.txt was empty.

I ran: exiftool -a -u -g1 /Users/Aagesen/ExifTool_ExportFile/TOMT/02_Video_Kamera_tømt_25122009/018_25_07_2009.MOD
---- ExifTool ----
ExifTool Version Number         : 9.55
---- System ----
File Name                       : 018_25_07_2009.MOD
Directory                       : /Users/Aagesen/ExifTool_ExportFile/TOMT/02_Video_Kamera_tømt_25122009
File Size                       : 94 MB
File Modification Date/Time     : 2009:07:25 19:57:32+02:00
File Access Date/Time           : 2014:07:10 07:24:30+02:00
File Inode Change Date/Time     : 2014:07:09 19:43:01+02:00
File Permissions                : rwxr-xr-x
---- File ----
File Type                       : MPEG
MIME Type                       : video/mpeg

My conclusion : no datetimeoriginal and therefor I usend FileModifyDate

Exiftool –ext MOD 'directory</Users/Aagesen/ExifTool_ExportFile/Billeder_Efter_Dato/$filemodifydate/' -d "%Y/%m" -r  /Users/Aagesen/ExifTool_ExportFile/TOMT/02_Video_Kamera_tømt_25122009
File not found: –ext
File not found: MOD
File not found: directory</Users/Aagesen/ExifTool_ExportFile/Billeder_Efter_Dato/$filemodifydate/
    1 directories scanned
    0 image files read
    3 files could not be read

Quistion 1) Can I split/convert date from the filename and put it into datetimeoriginal - and will that do the job ?
Quistion 2) Can I use date in filename directly for moving files to correct new folder ?

/Aage
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Hayo Baan on July 10, 2014, 02:25:30 AM
Hi Aage,

A couple of simple mistakes in your command make it fail.  The dash in front of ext is not a real dash (minus sign) and the directory<... Has no dash in front of it at all.

Don't know if it does exactly what you want, but if you change your command to exiftool -ext MOD '-directory</Users/Aagesen/ExifTool_ExportFile/Billeder_Efter_Dato/$filemodifydate/' -d "%Y/%m" -r  /Users/Aagesen/ExifTool_ExportFile/TOMT/02_Video_Kamera_tømt_25122009
It'll probably work.

Hope that helps,
Hayo
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on July 11, 2014, 02:29:15 PM
Thanks a lot, Hayo !

It works super !!!!!

I will do some categorization and then be back for some more help ;-)

Talk to you guys later !

/Aage
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on July 11, 2014, 05:39:17 PM
Hi Phil (and others)

A quick one ;-)

I have lots of files with name like : Canon_02102011_L4Y2M_J1Y5M_0001.JPG

I run : exiftool '-subject<${filename;s/_\d+_\d+_\d+\..*//}' -sep "_" -r DIR

File "Canon_02102011_L4Y2M_J1Y5M_0001.JPG" now have the following tags in Picasa :
L4Y2M
J1Y5M
Canon
02102011
0001.JPG

That is fantastic because now I have metadata in both filename and as tags - SUPER !!!

Quistion: I want all above tags to be created running Phil´s code above EXECPT from the "0001.JPG". How do I modify the above code to prevent this from happening ?

P.S. I also found an explanation for why I suddenly got "extra" file in my DIR. Super documentation and now I know about "-overwrite_original" ;-)

/Aage
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Hayo Baan on July 12, 2014, 03:19:46 AM
I think exiftool '-subject<${filename;s/_\d+\..*$//;}' -sep "_" -r DIR
will do the trick. In your original code, your replacement string never matched as the groups did not exist solely of digits (\d).

HTH,
Hayo
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on July 21, 2014, 11:50:11 AM
Hi

I actually works – thanks a lot ;-)

What I have done so far is the following passes and my below question relates to Step 2:

STEP 1: RENAME files

exiftool -config Aage3.config -ext MOD -ext JPG –ext AVI -ext avi -ext MPG -r '-filename<$myfilename%+.4nc.%e' /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

STEP 2: Delete all "old, stupid and un-wanted" XMP-tags

? ? ?

STEP 3: Add XMP-tags to all files

exiftool '-subject<${filename;s/_\d+\..*$//;}' -sep "_" -r /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

STEP 4: Move files to new folder-structure

exiftool -ext AVI -ext JPG '-directory</Users/Aagesen/ExifTool_ExportFile/Billeder_Efter_Dato/$datetimeoriginal/' -d "%Y/%m" -r  /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe


I have been reading about tags and there is apparently A LOT to consider and I am afraid that I will miss something out – so therefor this question:

Before adding my new XMP-tags in Step 3, I would like to ensure that there are no "old, stupid and un-wanted" tags in my files. I would like to write a command that deletes all "old, stupid and un-wanted" tags that are shown in Picasa before I run Step 3. The command should not delete all META-data at all ;-)

So my new command should delete all "old, stupid and un-wanted" tags only leaving me with the following tags in Picasa:

Example-File "Canon_02102011_L4Y2M_J1Y5M_0001.JPG" now have the following tags in Picasa :
L4Y2M
J1Y5M
Canon
02102011

Quistion: What should the command look like and why ?

/Aage
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on July 21, 2014, 12:00:00 PM
Hi Aage,

Read FAQ 2 (https://exiftool.org/faq.html#Q2), and for each tag you want to delete, add an option like -xmp:SOMETAG= on the command line.  You can add these argments to the command in step 3, before you set xmp:subject.

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on July 21, 2014, 02:01:15 PM
Hi Phil

Thanks once again !

I have been reading and testing for a while now and underneath I paste the full text from my terminal-window after I have extracted, modified and again extracted data:

Text from my Terminal-window:
--------------------------------------
Aagesens-Mac-mini:~ Aagesen$ exiftool -a -s -g1 /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe_Kopi/vvv0001.JPG
---- ExifTool ----
ExifToolVersion                 : 9.55
---- System ----
FileName                        : vvv0001.JPG
Directory                       : /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe_Kopi
FileSize                        : 8.9 MB
FileModifyDate                  : 2014:07:21 19:06:42+02:00
FileAccessDate                  : 2014:07:21 19:44:56+02:00
FileInodeChangeDate             : 2014:07:21 19:06:44+02:00
FilePermissions                 : rw-r--r--
---- File ----
FileType                        : JPEG
MIMEType                        : image/jpeg
ExifByteOrder                   : Big-endian (Motorola, MM)
CurrentIPTCDigest               : 7a1ec72cd634560df399ee705c9040d1
ImageWidth                      : 5184
ImageHeight                     : 3456
EncodingProcess                 : Baseline DCT, Huffman coding
BitsPerSample                   : 8
ColorComponents                 : 3
YCbCrSubSampling                : YCbCr4:2:2 (2 1)
---- IFD0 ----
Make                            : Canon
Model                           : Canon EOS 600D
Orientation                     : Horizontal (normal)
XResolution                     : 72
YResolution                     : 72
ResolutionUnit                  : inches
Software                        : Picasa
ModifyDate                      : 2014:07:21 19:06:43
Artist                          : Lars Aagesen
YCbCrPositioning                : Co-sited
Copyright                       :
XPKeywords                      : xxx_ccc
Padding                         : (Binary data 2060 bytes, use -b option to extract)
---- ExifIFD ----
ExposureTime                    : 1/200
FNumber                         : 11.0
ExposureProgram                 : Program AE
ISO                             : 400
SensitivityType                 : Recommended Exposure Index
RecommendedExposureIndex        : 400
ExifVersion                     : 0230
DateTimeOriginal                : 2013:05:14 18:46:21
CreateDate                      : 2013:05:14 18:46:21
ComponentsConfiguration         : Y, Cb, Cr, -
ShutterSpeedValue               : 1/197
ApertureValue                   : 11.3
ExposureCompensation            : 0
MeteringMode                    : Multi-segment
Flash                           : On, Fired
FocalLength                     : 84.0 mm
UserComment                     :
SubSecTime                      : 00
SubSecTimeOriginal              : 00
SubSecTimeDigitized             : 00
FlashpixVersion                 : 0100
ColorSpace                      : sRGB
ExifImageWidth                  : 5184
ExifImageHeight                 : 3456
FocalPlaneXResolution           : 5728.176796
FocalPlaneYResolution           : 5808.403361
FocalPlaneResolutionUnit        : inches
CustomRendered                  : Normal
ExposureMode                    : Auto
WhiteBalance                    : Auto
SceneCaptureType                : Standard
ImageUniqueID                   : 753fb024ca396a6febaf53c19f57ac54
OwnerName                       :
SerialNumber                    : 103063016966
LensInfo                        : 18-200mm f/?
LensModel                       : 18-200mm
LensSerialNumber                : 0000000000
Padding                         : (Binary data 2060 bytes, use -b option to extract)
OffsetSchema                    : 4038
---- IFD1 ----
Compression                     : JPEG (old-style)
XResolution                     : 72
YResolution                     : 72
ResolutionUnit                  : inches
ThumbnailOffset                 : 5536
ThumbnailLength                 : 5325
---- XMP-x ----
XMPToolkit                      : XMP Core 5.1.2
---- XMP-xmp ----
Rating                          : 0
ModifyDate                      : 2014:07:21 19:06:43+02:00
---- XMP-microsoft ----
DateAcquired                    : 2013:07:21 05:14:24.055
LastKeywordXMP                  : xxx_ccc
---- XMP-dc ----
Subject                         : tagFRApicasa, xxx_ccc
---- IPTC ----
EnvelopeRecordVersion           : 4
CodedCharacterSet               : UTF8
ApplicationRecordVersion        : 4
Keywords                        : tagFRApicasa, xxx_ccc
---- Photoshop ----
IPTCDigest                      : 7a1ec72cd634560df399ee705c9040d1
---- Composite ----
Aperture                        : 11.0
ImageSize                       : 5184x3456
ScaleFactor35efl                : 1.6
ShutterSpeed                    : 1/200
SubSecCreateDate                : 2013:05:14 18:46:21.00
SubSecDateTimeOriginal          : 2013:05:14 18:46:21.00
SubSecModifyDate                : 2014:07:21 19:06:43.00
ThumbnailImage                  : (Binary data 5325 bytes, use -b option to extract)
CircleOfConfusion               : 0.019 mm
FOV                             : 15.5 deg
FocalLength35efl                : 84.0 mm (35 mm equivalent: 132.1 mm)
HyperfocalDistance              : 33.58 m
LightValue                      : 12.6
Aagesens-Mac-mini:~ Aagesen$ exiftool -xmp:Keywords= -xmp:Subject= -xmp:LastKeywordXMP= -xmp:XPKeywords= /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe_Kopi/vvv0001.JPG
Warning: Tag 'xmp:XPKeywords' does not exist
    1 image files updated
Aagesens-Mac-mini:~ Aagesen$ exiftool -a -s -g1 /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe_Kopi/vvv0001.JPG
---- ExifTool ----
ExifToolVersion                 : 9.55
---- System ----
FileName                        : vvv0001.JPG
Directory                       : /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe_Kopi
FileSize                        : 8.9 MB
FileModifyDate                  : 2014:07:21 19:48:28+02:00
FileAccessDate                  : 2014:07:21 19:48:32+02:00
FileInodeChangeDate             : 2014:07:21 19:48:28+02:00
FilePermissions                 : rw-r--r--
---- File ----
FileType                        : JPEG
MIMEType                        : image/jpeg
ExifByteOrder                   : Big-endian (Motorola, MM)
CurrentIPTCDigest               : 7a1ec72cd634560df399ee705c9040d1
ImageWidth                      : 5184
ImageHeight                     : 3456
EncodingProcess                 : Baseline DCT, Huffman coding
BitsPerSample                   : 8
ColorComponents                 : 3
YCbCrSubSampling                : YCbCr4:2:2 (2 1)
---- IFD0 ----
Make                            : Canon
Model                           : Canon EOS 600D
Orientation                     : Horizontal (normal)
XResolution                     : 72
YResolution                     : 72
ResolutionUnit                  : inches
Software                        : Picasa
ModifyDate                      : 2014:07:21 19:06:43
Artist                          : Lars Aagesen
YCbCrPositioning                : Co-sited
Copyright                       :
XPKeywords                      : xxx_ccc
Padding                         : (Binary data 2060 bytes, use -b option to extract)
---- ExifIFD ----
ExposureTime                    : 1/200
FNumber                         : 11.0
ExposureProgram                 : Program AE
ISO                             : 400
SensitivityType                 : Recommended Exposure Index
RecommendedExposureIndex        : 400
ExifVersion                     : 0230
DateTimeOriginal                : 2013:05:14 18:46:21
CreateDate                      : 2013:05:14 18:46:21
ComponentsConfiguration         : Y, Cb, Cr, -
ShutterSpeedValue               : 1/197
ApertureValue                   : 11.3
ExposureCompensation            : 0
MeteringMode                    : Multi-segment
Flash                           : On, Fired
FocalLength                     : 84.0 mm
UserComment                     :
SubSecTime                      : 00
SubSecTimeOriginal              : 00
SubSecTimeDigitized             : 00
FlashpixVersion                 : 0100
ColorSpace                      : sRGB
ExifImageWidth                  : 5184
ExifImageHeight                 : 3456
FocalPlaneXResolution           : 5728.176796
FocalPlaneYResolution           : 5808.403361
FocalPlaneResolutionUnit        : inches
CustomRendered                  : Normal
ExposureMode                    : Auto
WhiteBalance                    : Auto
SceneCaptureType                : Standard
ImageUniqueID                   : 753fb024ca396a6febaf53c19f57ac54
OwnerName                       :
SerialNumber                    : 103063016966
LensInfo                        : 18-200mm f/?
LensModel                       : 18-200mm
LensSerialNumber                : 0000000000
Padding                         : (Binary data 2060 bytes, use -b option to extract)
OffsetSchema                    : 4038
---- IFD1 ----
Compression                     : JPEG (old-style)
XResolution                     : 72
YResolution                     : 72
ResolutionUnit                  : inches
ThumbnailOffset                 : 5536
ThumbnailLength                 : 5325
---- XMP-x ----
XMPToolkit                      : Image::ExifTool 9.55
---- XMP-microsoft ----
DateAcquired                    : 2013:07:21 05:14:24.055
---- XMP-xmp ----
ModifyDate                      : 2014:07:21 19:06:43+02:00
Rating                          : 0
---- IPTC ----
EnvelopeRecordVersion           : 4
CodedCharacterSet               : UTF8
ApplicationRecordVersion        : 4
Keywords                        : tagFRApicasa, xxx_ccc
---- Photoshop ----
IPTCDigest                      : 7a1ec72cd634560df399ee705c9040d1
---- Composite ----
Aperture                        : 11.0
ImageSize                       : 5184x3456
ScaleFactor35efl                : 1.6
ShutterSpeed                    : 1/200
SubSecCreateDate                : 2013:05:14 18:46:21.00
SubSecDateTimeOriginal          : 2013:05:14 18:46:21.00
SubSecModifyDate                : 2014:07:21 19:06:43.00
ThumbnailImage                  : (Binary data 5325 bytes, use -b option to extract)
CircleOfConfusion               : 0.019 mm
FOV                             : 15.5 deg
FocalLength35efl                : 84.0 mm (35 mm equivalent: 132.1 mm)
HyperfocalDistance              : 33.58 m
LightValue                      : 12.6
Aagesens-Mac-mini:~ Aagesen$
--------------------------------------

Note that I am trying to delete all content from the following Tag-names:

XPKeywords
LastkeywordXMP
Subject
Keywords

Terminal tells me that XPKeywords doest not exist.

Quistion: Why are only content from "Lastkeyword" and "Subject" deleted and what to do for fixing this ?

/Aage

Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Hayo Baan on July 21, 2014, 02:44:45 PM
You are trying to remove the XMP tags Keywords and XPKeywords. However, these are not XMP tags, they are IPTC and EXIF tags respectively. If you remove the xmp: in front of these two tags, you'll have your result. You can (should?) actually leave xmp: off of all tags; exiftool will sort out what to delete for you, and also take care any duplicates (use -a to view those too).

exiftool -Keywords= -Subject= -LastKeywordXMP= -XPKeywords= /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe_Kopi/vvv0001.JPG

Hope this helps,
Hayo
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on July 21, 2014, 03:17:20 PM
Thank you so very much !

I love EXIF Tool and the support that is provided by all you gifted people  :) :) :)

/Aage
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: klarakos on August 01, 2014, 05:50:53 AM
We could use FileModifyDate if the other date/time tags aren't available.  I could build this into the config file, but I don't have the time right now.  Give me until tomorrow morning and I'll come up with something for you.
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Phil Harvey on August 01, 2014, 07:25:52 AM
You don't need a config file to use FileModifyDate if the other tags aren't available.  Just add another argument before the others on the command line, but using FileModifyDate instead of the other date/time tag(s).

- Phil
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on August 12, 2014, 02:19:19 PM
Hi again

Before I run the big test on all files I wonder if I should change the way that I do things. This has come to my mind while I was thinking about the trailing number that the configfile adds to all files that are renamed.

This is what I do :

Step 1 : Rename all files
exiftool -config Aage3.config -ext MOD -ext JPG –ext AVI -ext avi -ext MPG -r '-filename<$myfilename%+.4nc.%e' /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

STEP 2: Delete all XMP-tags
exiftool -Keywords= -Subject= -LastKeywordXMP= -XPKeywords= /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

STEP 3: Add XMP-tags to all files
exiftool '-subject<${filename;s/_\d+\..*$//;}' -sep "_" -r /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

STEP 4a: Move all files (JPG+AVI) to new folder-structure
exiftool -ext AVI -ext JPG '-directory</Users/Aagesen/ExifTool_ExportFile/Billeder_Efter_Dato/$datetimeoriginal/' -d "%Y/%m" -r  /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

STEP 4b: Move all files (MOD) to new folder-structure
exiftool -ext MOD '-directory</Users/Aagesen/ExifTool_ExportFile/Billeder_Efter_Dato/$filemodifydate/' -d "%Y/%m" -r  /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

My thouhgt:
Maybe I shold run Step 4a+Step 4b before running Step 1 and add a SORTING command right after Step 4a + Step 4b. The purpose of this new SORTING-Step should be to ensure that the trailing number added to all renamed files by the configfile indicates the correct sort-order. The correct sort-order should be "oldest-to-newest" based on (in this priority) DateTimeOriginal, DateTaken, DateModify.

Quistion 1:
Do you think I should do as described under "My thoughts" ?

Quistion 2:
How should the sorting-command look like to achieve the corret sort-order/adding correct trailing number ?

/Aage
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Hayo Baan on August 12, 2014, 03:25:46 PM
Hi Aage,

Sorting your files to get a sequence number that also indicates sort order sounds like a good idea. The command-line option to specify that is -fileOrder, but you probably knew that already ;)

The tough thing would be to get it to use the correct tag as not all files will have e.g., DateTimeOriginal.
To solve this, I suggest to create a new custom field in the .Exiftool_config file.

Something like this:
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MySortDate => {
            Desire => {
                0 => 'DateTimeOriginal',
                1 => 'DateTaken',
                2 => 'FileModifyDate',
            },
            ValueConv =>
                '$val[0] || $val[1] || $val[2]',
        },
    },
);


If you use this tag you can combine step 4a and 4b into one as well :)

Note: I have not really tested the code, but it apart from some minor things, it should work.
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on August 13, 2014, 01:23:22 AM
Hi Hayo

Thanks for helping me out and yes, I found the -fileOrder command ;-)

The problem is excatly as you describe and I did not manage to put the code together myself or modify the config-file that Phil made for me. I am not that good at programming ;-)

Just to get this right :

1) Add your code to my config-file.
2) Use the same config-file for both renaming and sorting - but in the renamingstep use var "MyFileName" and in the sortingstep use var "MySortDate"
3) Merge Step4a and Step4b using the var "MySortDate".

Quistion 1) Did I get it right ?
Quistion 2) Can you add your code in my config-file "Aage3.config" (attatched in this post) ?
Quistion 3) How do I run the sorting-step from the config-file ?
Quistion 4) How should a merged Step4a + Step4b look like considering the original code (exiftool -ext AVI -ext JPG '-directory</Users/Aagesen/ExifTool_ExportFile/Billeder_Efter_Dato/$datetimeoriginal/' -d "%Y/%m" -r  /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe) ?

I really appreciate you help ;-)

/Aage

P.S. Very nice pictures on your webpage ! The Industrial heritage section is my favorite with all the "lines" !!
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Hayo Baan on August 13, 2014, 03:27:12 AM
Quote from: aage on August 13, 2014, 01:23:22 AM
Thanks for helping me out and yes, I found the -fileOrder command ;-)

You're welcome!

Quote from: aage on August 13, 2014, 01:23:22 AM
The problem is excatly as you describe and I did not manage to put the code together myself or modify the config-file that Phil made for me. I am not that good at programming ;-)

Just to get this right :

1) Add your code to my config-file.
2) Use the same config-file for both renaming and sorting - but in the renamingstep use var "MyFileName" and in the sortingstep use var "MySortDate"
3) Merge Step4a and Step4b using the var "MySortDate".

Quistion 1) Did I get it right ?

Yep!

Quote from: aage on August 13, 2014, 01:23:22 AM
Quistion 2) Can you add your code in my config-file "Aage3.config" (attatched in this post) ?

Yep!

Quote from: aage on August 13, 2014, 01:23:22 AM
Quistion 3) How do I run the sorting-step from the config-file ?
Quistion 4) How should a merged Step4a + Step4b look like considering the original code (exiftool -ext AVI -ext JPG '-directory</Users/Aagesen/ExifTool_ExportFile/Billeder_Efter_Dato/$datetimeoriginal/' -d "%Y/%m" -r  /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe) ?

Like this:

Step 1 : Rename all files
exiftool -config Aage3.config -ext MOD -ext JPG –ext AVI -ext MPG -r -fileOrder MySortName '-filename<$myfilename%+.4nc.%e' /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

STEP 2: Delete all XMP-tags
exiftool -Keywords= -Subject= -LastKeywordXMP= -XPKeywords= /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe
(unchanged)

STEP 3: Add XMP-tags to all files
exiftool '-subject<${filename;s/_\d+\..*$//;}' -sep "_" -r /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe
(unchanged)

STEP 4: Move all files (JPG+AVI+MOD+MPG) to new folder-structure
exiftool -config Aage3.config -ext AVI -ext JPG -ext MOD -ext MPG '-directory</Users/Aagesen/ExifTool_ExportFile/Billeder_Efter_Dato/$MySortDate/' -d "%Y/%m" -r  /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

With the new Aage3.config, this should work:
sub MakeCode($$$)
{
    my @date1 = split /[: ]/, shift;
    my @date2 = split /[: ]/, shift;
    my $name = shift;
    my $years = $date1[0] - $date2[0];
    my $months = $date1[1] - $date2[1];
    my $days = $date1[2] - $date2[2];
    if ($days < 0) { --$months; }
    if ($months < 0) { $months += 12; --$years; }
    my $str = '';
    $str .= "${years}Y" if $years > 0;
    $str .= "${months}M" if $months > 0 and $years >= 0;
    $str = "_$name$str" if $str;
    return $str;
}

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyFileName => {
            Desire => {
                0 => 'Make',
                1 => 'DateTimeOriginal',
                2 => 'CreateDate',
                3 => 'FileModifyDate',
            },
            ValueConv => sub {
                my $vals = shift;
                my $make = $$vals[0];
                my $date = $$vals[1] || $$vals[2] || $$vals[3] or return undef;
                my $daughter = MakeCode($date, '2007:07:27', 'L');
                my $son = MakeCode($date, '2010:04:27', 'J');
                if (defined $make) {
                    $make =~ tr(/\\?*:|"<>\0)()d; # remove illegal characters
                    $make .= '_';
                } else {
                    $make = '';
                }
                my @parts = split /[: ]/, $date;
                return "${make}$parts[2]$parts[1]$parts[0]$daughter$son";
            },
        },
        MySortDate => {
            Desire => {
                0 => 'DateTimeOriginal',
                1 => 'CreateDate',
                2 => 'FileModifyDate',
            },
            ValueConv =>
                '$val[0] || $val[1] || $val[2]',
            PrintConv => '$self->ConvertDateTime($val)',
        },
    },
);
1;  #end


Quote from: aage on August 13, 2014, 01:23:22 AM
P.S. Very nice pictures on your webpage ! The Industrial heritage section is my favorite with all the "lines" !!

Thanks :)
In October (weekend of 11+12 October, I again lead an Industrial Heritage (http://www.hayobaan.nl/Workshops/Industrial%20Heritage) photography workshop in Dortmund, there are still a couple of seats left, so if you want you can join us ;))

Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on August 13, 2014, 03:23:45 PM
Hi Hayo

THANK you so much !!!

Your new version of the config-file and the command-lines in each step is just plain "Plug-and-Play" - it worked perfectly ;-) ;-)

Only a small quistion before I run the BIG test ;-)

After sorting and renaming in Step 1 all the files have the correct trailing number - as long as they resides in the original folder.
BUT Step 4 move all files to the new folderstructure.

Because of my original folderstructure I will have files from different "original folders" added to the new folderstructure and the trailing number will no longer be a trailing number in the new folder - because files from same day could come from different "original folders" ;-)

Quistion 1) Can I run Step 1 in a modyfied way as a final Step 5 to ensure correct trailing number in the new folderstructure ?
Quistion 2) How should the modyfied commandline look like for "Step 5 : Correct trailing number for all files in new folderstructure" ?

/Aage

P.S. The Industrial Heritage photography workshop in Dortmund sounds cool - but I will be driving around in a Polish wood in my old Land Rover in this period ;-) Thanks for the invite anyway ;-)
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Hayo Baan on August 13, 2014, 03:54:01 PM
Quote from: aage on August 13, 2014, 03:23:45 PM
Hi Hayo

THANK you so much !!!

Your new version of the config-file and the command-lines in each step is just plain "Plug-and-Play" - it worked perfectly ;-) ;-)

Excellent! Good to hear (I did test the individual components, but couldn't test the whole, of course).

Quote from: aage on August 13, 2014, 03:23:45 PM
Only a small quistion before I run the BIG test ;-)

After sorting and renaming in Step 1 all the files have the correct trailing number - as long as they resides in the original folder.
BUT Step 4 move all files to the new folderstructure.

Because of my original folderstructure I will have files from different "original folders" added to the new folderstructure and the trailing number will no longer be a trailing number in the new folder - because files from same day could come from different "original folders" ;-)

Quistion 1) Can I run Step 1 in a modyfied way as a final Step 5 to ensure correct trailing number in the new folderstructure ?
Quistion 2) How should the modyfied commandline look like for "Step 5 : Correct trailing number for all files in new folderstructure" ?

Right, so basically what you want is to have the files in each directory with their own sequence. Then, why don't we just skip the first step and do it at the end. You'll have to adjust step 3 for this though.

exiftool -config Aage3.config '-subject<${myfilename;s/\..*$//;}' -sep "_" -r /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe

Step 5 would then basically the same as the first step (we don't perform any more) but then called on each of the new dated directories individually.

By the way I noticed I made a mistake in step one, I used -fileOrder MySortName, but it should have been -fileOrder MySortDate, of course.

Quote from: aage on August 13, 2014, 03:23:45 PM
P.S. The Industrial Heritage photography workshop in Dortmund sounds cool - but I will be driving around in a Polish wood in my old Land Rover in this period ;-) Thanks for the invite anyway ;-)
That also sounds great! Have fun :)
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on August 20, 2014, 04:13:02 PM
Hi Hayo (and other readers)

I am now testing the order of steps and it look quite good - but i discovered a strange thing:

When Picasa reads info in the picture "Canon_02102011_L4Y2M_J1Y5M_0001.JPG" - Picasa tells me that the TAG "Billeder_tømt_24122011" exist in this picture.

But I can´t find this TAG using ExifTool like this:

----------------------------------------------------------
exiftool -a -s -g1 /Users/Aagesen/ExifTool_ExportFile/Filer_til_ExifTEST/2_Aug2011_Dec2011/Canon_02102011_L4Y2M_J1Y5M_0001.JPG
---- ExifTool ----
ExifToolVersion                 : 9.55
---- System ----
FileName                        : Canon_02102011_L4Y2M_J1Y5M_0001.JPG
Directory                       : /Users/Aagesen/ExifTool_ExportFile/Filer_til_ExifTEST/2_Aug2011_Dec2011
FileSize                        : 3.0 MB
FileModifyDate                  : 2014:08:20 20:34:05+02:00
FileAccessDate                  : 2014:08:20 21:56:05+02:00
FileInodeChangeDate             : 2014:08:20 20:34:05+02:00
FilePermissions                 : rw-rw-rw-
---- File ----
FileType                        : JPEG
MIMEType                        : image/jpeg
ExifByteOrder                   : Big-endian (Motorola, MM)
ImageWidth                      : 3888
ImageHeight                     : 2592
EncodingProcess                 : Baseline DCT, Huffman coding
BitsPerSample                   : 8
ColorComponents                 : 3
YCbCrSubSampling                : YCbCr4:2:2 (2 1)
---- IFD0 ----
Make                            : Canon
Model                           : Canon EOS 400D DIGITAL
Orientation                     : Horizontal (normal)
XResolution                     : 72
YResolution                     : 72
ResolutionUnit                  : inches
ModifyDate                      : 2011:10:02 08:47:39
YCbCrPositioning                : Co-sited
Padding                         : (Binary data 2060 bytes, use -b option to extract)
---- ExifIFD ----
ExposureTime                    : 1/60
FNumber                         : 5.0
ExposureProgram                 : Program AE
ISO                             : 400
ExifVersion                     : 0221
DateTimeOriginal                : 2011:10:02 08:47:39
CreateDate                      : 2011:10:02 08:47:39
ComponentsConfiguration         : Y, Cb, Cr, -
ShutterSpeedValue               : 1/60
ApertureValue                   : 5.0
ExposureCompensation            : 0
MeteringMode                    : Multi-segment
Flash                           : Auto, Fired, Red-eye reduction
FocalLength                     : 50.0 mm
UserComment                     :
FlashpixVersion                 : 0100
ColorSpace                      : sRGB
ExifImageWidth                  : 3888
ExifImageHeight                 : 2592
FocalPlaneXResolution           : 4433.295325
FocalPlaneYResolution           : 4453.608247
FocalPlaneResolutionUnit        : inches
CustomRendered                  : Normal
ExposureMode                    : Auto
WhiteBalance                    : Auto
SceneCaptureType                : Standard
Padding                         : (Binary data 2060 bytes, use -b option to extract)
OffsetSchema                    : 4160
---- Canon ----
MacroMode                       : Normal
SelfTimer                       : Off
Quality                         : Fine
CanonFlashMode                  : Red-eye reduction (Auto)
ContinuousDrive                 : Single
FocusMode                       : AI Focus AF
RecordMode                      : JPEG
CanonImageSize                  : Large
EasyMode                        : Full auto
DigitalZoom                     : None
Contrast                        : Normal
Saturation                      : Normal
Sharpness                       : +3
MeteringMode                    : Evaluative
FocusRange                      : Not Known
CanonExposureMode               : Easy
LensType                        : Canon EF 35-350mm f/3.5-5.6L or Sigma or Tamron Lens
MaxFocalLength                  : 200 mm
MinFocalLength                  : 18 mm
FocalUnits                      : 1/mm
MaxAperture                     : 4
MinAperture                     : 27
FlashActivity                   : 0
FlashBits                       : E-TTL, Built-in
FocusContinuous                 : Single
ZoomSourceWidth                 : 0
ZoomTargetWidth                 : 0
PhotoEffect                     : Off
ManualFlashOutput               : n/a
ColorTone                       : Normal
FocalType                       : Zoom
FocalLength                     : 50 mm
FocalPlaneXSize                 : 23.04 mm
FocalPlaneYSize                 : 15.37 mm
AutoISO                         : 100
BaseISO                         : 400
MeasuredEV                      : 8.62
TargetAperture                  : 5
TargetExposureTime              : 1/64
ExposureCompensation            : 0
WhiteBalance                    : Auto
SlowShutter                     : None
SequenceNumber                  : 0
OpticalZoomCode                 : n/a
CameraTemperature               : 25 C
FlashExposureComp               : 0
AutoExposureBracketing          : Off
AEBBracketValue                 : 0
ControlMode                     : Camera Local Control
FNumber                         : 5
ExposureTime                    : 1/64
MeasuredEV2                     : 8.625
BulbDuration                    : 0
CameraType                      : EOS Mid-range
AutoRotate                      : None
NDFilter                        : n/a
SelfTimer2                      : 0
CanonImageType                  : Canon EOS 400D DIGITAL
CanonFirmwareVersion            : Firmware 1.1.0
OwnerName                       : unknown
SerialNumber                    : 1430801993
CanonModelID                    : EOS Digital Rebel XTi / 400D / Kiss Digital X
NumAFPoints                     : 9
ValidAFPoints                   : 9
CanonImageWidth                 : 3888
CanonImageHeight                : 2592
AFImageWidth                    : 3504
AFImageHeight                   : 2336
AFAreaWidth                     : 78
AFAreaHeight                    : 78
AFAreaXPositions                : 8 -555 571 -931 8 947 -555 571 8
AFAreaYPositions                : 504 270 270 4 4 4 -262 -262 -496
AFPointsInFocus                 : 1,3,4
ThumbnailImageValidArea         : 0 159 7 112
SerialNumberFormat              : Format 2
OriginalDecisionDataOffset      : 0
FileNumber                      : 159-9501
BracketMode                     : Off
BracketValue                    : 0
BracketShotNumber               : 0
LongExposureNoiseReduction2     : Off
WBBracketMode                   : Off
WBBracketValueAB                : 0
WBBracketValueGM                : 0
FilterEffect                    : None
ToningEffect                    : None
LensModel                       :
InternalSerialNumber            : H2110372
DustRemovalData                 : (Binary data 1024 bytes, use -b option to extract)
CropLeftMargin                  : 0
CropRightMargin                 : 0
CropTopMargin                   : 0
CropBottomMargin                : 0
ToneCurve                       : Standard
Sharpness                       : 3
SharpnessFrequency              : n/a
SensorRedLevel                  : 0
SensorBlueLevel                 : 0
WhiteBalanceRed                 : 0
WhiteBalanceBlue                : 0
ColorTemperature                : 5200
PictureStyle                    : Standard
DigitalGain                     : 0
WBShiftAB                       : 0
WBShiftGM                       : 0
MeasuredRGGB                    : 833 1024 1024 594
ColorSpace                      : sRGB
VRDOffset                       : 0
SensorWidth                     : 3948
SensorHeight                    : 2622
SensorLeftBorder                : 52
SensorTopBorder                 : 23
SensorRightBorder               : 3939
SensorBottomBorder              : 2614
BlackMaskLeftBorder             : 0
BlackMaskTopBorder              : 0
BlackMaskRightBorder            : 0
BlackMaskBottomBorder           : 0
ColorDataVersion                : 1 (1DmkIIN/5D/30D/400D)
WB_RGGBLevelsAsShot             : 2171 1024 1024 1608
ColorTempAsShot                 : 4921
WB_RGGBLevelsAuto               : 2171 1024 1024 1608
ColorTempAuto                   : 4921
WB_RGGBLevelsMeasured           : 2165 1024 1021 1604
ColorTempMeasured               : 4921
WB_RGGBLevelsDaylight           : 2245 1024 1024 1533
ColorTempDaylight               : 5200
WB_RGGBLevelsShade              : 2655 1024 1024 1282
ColorTempShade                  : 7000
WB_RGGBLevelsCloudy             : 2456 1024 1024 1394
ColorTempCloudy                 : 6000
WB_RGGBLevelsTungsten           : 1553 1070 1070 2494
ColorTempTungsten               : 3200
WB_RGGBLevelsFluorescent        : 1856 1024 1024 2118
ColorTempFluorescent            : 3769
WB_RGGBLevelsKelvin             : 2245 1024 1024 1533
ColorTempKelvin                 : 5210
WB_RGGBLevelsFlash              : 2717 1024 1024 1274
ColorTempFlash                  : 7199
WB_RGGBLevelsPC1                : 8191 1024 1024 8191
ColorTempPC1                    : 4533
WB_RGGBLevelsPC2                : 8191 1024 1024 8191
ColorTempPC2                    : 4533
WB_RGGBLevelsPC3                : 8191 1024 1024 8191
ColorTempPC3                    : 4533
WB_RGGBLevelsCustom             : 2245 1024 1024 1533
ColorTempCustom                 : 5210
PerChannelBlackLevel            : 256 256 256 255
FlashOutput                     : 14%
FlashBatteryLevel               : 5.40V
MeasuredRGGBData                : 29556 36721 36872 21226
CustomPictureStyleFileName      :
---- CanonCustom ----
SetButtonCrossKeysFunc          : Set: Picture Style
LongExposureNoiseReduction      : Off
FlashSyncSpeedAv                : Auto
Shutter-AELock                  : AF/AE lock
AFAssistBeam                    : Emits
ExposureLevelIncrements         : 1/3 Stop
MirrorLockup                    : Disable
ETTLII                          : Evaluative
ShutterCurtainSync              : 1st-curtain sync
MagnifiedView                   : Image playback only
LCDDisplayAtPowerOn             : Display
---- InteropIFD ----
InteropVersion                  : 0100
---- IFD1 ----
Compression                     : JPEG (old-style)
XResolution                     : 72
YResolution                     : 72
ResolutionUnit                  : inches
ThumbnailOffset                 : 10054
ThumbnailLength                 : 4060
---- XMP-x ----
XMPToolkit                      : Image::ExifTool 9.55
---- XMP-rdf ----
About                           : uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b
---- XMP-microsoft ----
DateAcquired                    : 2011:12:24 14:40:53.804
---- Composite ----
Aperture                        : 5.0
ConditionalFEC                  : 0
DriveMode                       : Single-frame Shooting
FlashType                       : Built-In Flash
ISO                             : 400
ImageSize                       : 3888x2592
Lens                            : 18.0 - 200.0 mm
LensID                          : Tamron AF 18-200mm f/3.5-6.3 XR Di II LD Aspherical [IF] Macro Model A14
RedEyeReduction                 : Off
ScaleFactor35efl                : 1.6
ShootingMode                    : Full auto
ShutterCurtainHack              : 1st-curtain sync
ShutterSpeed                    : 1/60
ThumbnailImage                  : (Binary data 4060 bytes, use -b option to extract)
WB_RGGBLevels                   : 2171 1024 1024 1608
BlueBalance                     : 1.570313
CircleOfConfusion               : 0.019 mm
FOV                             : 25.1 deg
FocalLength35efl                : 50.0 mm (35 mm equivalent: 80.9 mm)
HyperfocalDistance              : 26.93 m
Lens35efl                       : 18.0 - 200.0 mm (35 mm equivalent: 29.1 - 323.7 mm)
LightValue                      : 8.6
RedBalance                      : 2.120117
Aagesens-Mac-mini:~ Aagesen$
-----------------------------------------------------

Do you know how I should find this particular TAG and how I can delete the TAG in my Step 2?

STEP 2: Delete all XMP-tags
exiftool -Keywords= -Subject= -LastKeywordXMP= -XPKeywords= /Users/Aagesen/ExifTool_ExportFile/Oprindelig_Mappe


Kind regards
/Aage
...and still working
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: aage on September 01, 2014, 01:22:39 PM
Hi

Ignore my last post - nothing wrong with my metadata. It´s a BUG in PICASA and I found a work-around ;-)

/Aage
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: Alyssa on September 01, 2014, 03:02:10 PM
Hi
Sorry if I am using this thread but I have a similar issue.
I use a script to rename jpg/png files with the time date, however I realized today that it doesn't work on BMP, I've read that exiftool can read but can't operate with bmp files, isn't there any workaround for this?
Thanks
Title: Re: Rename photos by datetimeoriginal and calculate kids age
Post by: StarGeek on September 01, 2014, 05:59:51 PM
The reason it doesn't work with Bmp images is because there isn't any metadata in the format.  There isn't any date or time in the image to rename it with.