News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Rename photos by datetimeoriginal and calculate kids age

Started by aage, April 07, 2014, 03:43:04 PM

Previous topic - Next topic

aage

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

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

aage

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

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

aage

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 ;-)

Phil Harvey

Hi Lars,

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

Have a happy Easter too.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

aage

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

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

aage

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

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

aage

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

Hayo Baan

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
Hayo Baan – Photography
Web: www.hayobaan.nl

aage

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

aage

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

Hayo Baan

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
Hayo Baan – Photography
Web: www.hayobaan.nl