Copying Tags from several folders

Started by Thomas, October 20, 2012, 04:17:47 PM

Previous topic - Next topic

Thomas

Hi, Phil,

following up some questions that have been put forward in the forum concerning -tagsfromfile and relative paths:

For some historical reasons I have my photos stored using a folder structure as follows:

I:\2007 VacationFrenchAtlanticOceanCoast\JPG\rejected
I:\2007 VacationFrenchAtlanticOceanCoast\JPG\choice
I:\2007 VacationFrenchAtlanticOceanCoast\RAW

I:\2007 VacationTuscany\JPG\rejected
I:\2007 VacationTuscany\JPG\choice
I:\2007 VacationTuscany\RAW

...

My first question: In both JPG folders for each event there are the same photos as in the respective RAW folder as I took all photos in both file formats. The folder structure has usually the same depth but the lenght of folder names differs. That means in general terms: I:\Date Event\Format\(choice - yes or no). Do you see any chance to copy tags from RAW to JPG files using a single -tagsfromfile command for all events?

My second question: Unfortunately (to make things even more complex...), in some cases I have a folder structure like
I:\Date Event1\JPG\Date Sub-Event1-1\(choice - yes or no)
I:\Date Event1\JPG\Date Sub-Event1-2\(choice - yes or no);
i.e. both depth of folder structure (depending on wether a sub-event exists) and length of the folder names differ. You see any chance here to include event these folders in a single command (or two, the main thing being not to be confronted with hundreds of commands)?

If a succinct no ist the answer to both questions: Which type of folder structure would you recommend to have a proper regime for all the holiday and (much more common!) family events?

Thanks for all your help and patience!

Greetings, Thomas

Phil Harvey

[for others reading this post, I did not pay Thomas to ask this question... ;) ]

Hi Thomas,

You are in luck!  Last week I released ExifTool 9.03 with a new feature that will allow you to do exactly this:

exiftool -tagsfromfile %-:2dRAW/%f.NEF -ext jpg -r DIR

Where DIR is the name of the base directory ("I:" in your case?).  Here I assume that your raw files have a ".NEF" extension.  The %-:2d goes up 2 directory levels from the source JPG file.

If the RAW directory is sometimes up 3 levels, repeat the command with %-:3d instead to process these.

I can't suggest a directory structure for you.  This seems fine to me.  It really depends on what is best for you.  Personally I use this structure:

Pictures/2012/2012-10-20 Family
Pictures/2012/2012-10-20 Family/raw
Pictures/2012/2012-10-20 Family/others
Pictures/2012/2012-10-20 Family/others/raw
Pictures/2012/2012-12-25 Christmas
Pictures/2012/2012-12-25 Christmas/raw
etc...

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

Thomas

Hi, Phil,

that's hot! And yes you didn't either ask or pay me. :) I always should read the version history first. Anyway, your instructions helped me a lot.  ... For the rest of my posting: And yes, it's really not my intention to annoy you asking further questions. It's just to make a newbie feel being assured.

The first question should be fairly easy to answer: When copying single tags, the order of statements seems to matter and the correct order for e.g. -Alldates seems to be (assuming "I:\" as the base directory)
exiftool -tagsfromfile %-:2dRAW/%f.ARW -Alldates -ext jpg -r "I:\", right?

Next, having a 2 level order structure, I get error messages (error opening file) for the first level case, i.e. "I:\RAW". Of course, there are no pictures (they are in I:\Date Event1\RAW). It's not a problem for me, as the tags of the pictures in the second level folder are copied correctly. It just seems to be a kind of "reverse recursive" that you certainly intended or took into account when you implemented this new feature.

Third, I haven't told you the "whole truth" regarding my folder structure. I do not only have "RAW" and "JPG" folders but also "JPG-Original" folders, i.e.

I:\2007 VacationFrenchAtlanticOceanCoast\JPG\rejected
I:\2007 VacationFrenchAtlanticOceanCoast\JPG\choice
I:\2007 VacationFrenchAtlanticOceanCoast\JPG-Orginal
I:\2007 VacationFrenchAtlanticOceanCoast\RAW

I tried to copy tags from the "JPG-Original" folder (original jpg files) to the pictures stored in the "JPG" folder (jpg files I work with) and I was very delighted that it worked. It works even when copying tags from files to files of the same type! Am I right? However, I don't manage to copy tags from the "JPG" folder to the "JPG-Original" folder. The -r option seems to be connected with the destination folder. How do I account for sub-folders in the source directory?

Last (totally independent of the the questions above), when copying the -previewimage tag (Sony A350), I get a "no writable tags set" error message even though there are preview images in the source files. Can you also help me out here?

Thanks a lot!
Thomas

Phil Harvey

Hi Thomas,

Quote from: Thomas on October 21, 2012, 04:21:01 PM
The first question should be fairly easy to answer: When copying single tags, the order of statements seems to matter and the correct order for e.g. -Alldates seems to be (assuming "I:\" as the base directory)
exiftool -tagsfromfile %-:2dRAW/%f.ARW -Alldates -ext jpg -r "I:\", right?

Yes.

        -tagsFromFile SRCFILE or FMT
            Copy tag values from SRCFILE to FILE.  Tag names on the command
            line after this option specify the tags to be copied, or excluded
            from the copy.


QuoteNext, having a 2 level order structure, I get error messages (error opening file) for the first level case, i.e. "I:\RAW". Of course, there are no pictures (they are in I:\Date Event1\RAW). It's not a problem for me, as the tags of the pictures in the second level folder are copied correctly. It just seems to be a kind of "reverse recursive" that you certainly intended or took into account when you implemented this new feature.

If the RAW files are at a different level you will get this warning and no tags will copied.  I'm not sure what you mean by "reverse recursive", but I think things are going as designed.  This feature is a more advanced feature, and needs some thought to get it right.

QuoteThird, [...] It works even when copying tags from files to files of the same type! Am I right?

Yes.

QuoteHowever, I don't manage to copy tags from the "JPG" folder to the "JPG-Original" folder. The -r option seems to be connected with the destination folder. How do I account for sub-folders in the source directory?

The -r option applies to any directory name on the command line except arguments of other options (such as -tagsFromFile).  To copy tags from JPG to JPG-Original, you could do this:

exiftool -tagsfromfile %-:1dJPG-Original/%f.%e -i JPG-Original -ext JPG -r DIR

Here I added a -i option to ignore files in the JPG-Original directory.  Also, the -ext JPG causes other image types to be ignored.

QuoteLast (totally independent of the the questions above), when copying the -previewimage tag (Sony A350), I get a "no writable tags set" error message even though there are preview images in the source files. Can you also help me out here?

Note 3 in the -tagsFromFile documentation:

            3) The maker note information is copied as a block, so it isn't
            affected like other information by subsequent tag assignments on
            the command line.  Also, since the PreviewImage referenced from
            the maker notes may be rather large, it is not copied, and must be
            transferred separately if desired.


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

Thomas

Hi, Phil,

thnks for answering! By "reverse recursive" I meant the following: The error message "error opening file I:\RAW\DSC08423.ARW" indicates that exiftool not only copies tags from RAW files in the folder "I:\Date Event1\RAW" but also would copy tags from pictures in the folder "I:\RAW" (which is a parent folder, not a sub-folder/child folder).

I guess if exiftool copies also tags from files which are stored in a parent folder, an answer to my third question (copying from "...\JPG\rejected" and "...\JPG\choice" folders to "...\JPG-Original" folders in addition to your answer could have been to take a 3-level approach and use two separate commands for the "rejected" folders and the "choice" folders:

exiftool -tagsfromfile %-:3drejected/%f.%e -ext JPG -r "I:\" and
exiftool -tagsfromfile %-:3drchoice/%f.%e -ext JPG -r "I:\"; do you agree to that?

Concerning PreviewImage I understand that the preview images are too big as to have a fast batch copying process. I am not sure at this point of time what "separately" means. At least the statement

exiftool -tagsfromfile %-:2dRAW/%f.ARW -Previewimage -ext jpg -r "I:\"

returned an error message "no writable tags". I'll try and find out (hints are welcome, of course).

Greetings, Thomas

Phil Harvey

Hi Thomas,

Quote from: Thomas on October 22, 2012, 03:24:44 AM
By "reverse recursive" I meant the following: The error message "error opening file I:\RAW\DSC08423.ARW" indicates that exiftool not only copies tags from RAW files in the folder "I:\Date Event1\RAW" but also would copy tags from pictures in the folder "I:\RAW" (which is a parent folder, not a sub-folder/child folder).

It only does what you tell it.  "%-:2d" moves up 2 directory levels from the location of the JPG image.   "%-:3d" moves up 3.

QuoteConcerning PreviewImage I understand that the preview images are too big as to have a fast batch copying process. I am not sure at this point of time what "separately" means. At least the statement

exiftool -tagsfromfile %-:2dRAW/%f.ARW -Previewimage -ext jpg -r "I:\"

returned an error message "no writable tags". I'll try and find out (hints are welcome, of course).

This should work provided that the destination JPG image already contains the maker notes (and the Make/Model tags).  The PreviewImage is stored in the maker notes, so without them there is no place for it to go.  So this should work:

exiftool -tagsfromfile %-:2dRAW/%f.ARW -ext jpg -r "I:\"
exiftool -tagsfromfile %-:2dRAW/%f.ARW -Previewimage -ext jpg -r "I:\"

But I would try it on one file first before batch processing all of them.

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

Thomas

Hi, Phil,

I'm so glad everything worked fine! All tags were copied between the "JPG", "JPG-Original", and "RAW" folders including child folders. And also the preview images were copied. Of course, ExifTool only does what you tell it to do, I just needed some help translating "%-:2d" and "%-:3d".

Thank you for ExifTool and taking the time to advise people on how to do great things with their photos! And without an intention to be indiscreet: Thanks to your family and friends for letting you invest the time...

Greetings, Thomas

Thomas

Sorry to be back again... In your second posting you said
QuoteTo copy tags from JPG to JPG-Original, you could do this:

exiftool -tagsfromfile %-:1dJPG-Original/%f.%e -i JPG-Original -ext JPG -r DIR

I'm afraid here I was to early to report good news. As far as I can see the copy process is from the source "JPG-Original" folder to the destination "JPG" folder. When I insert "JPG" (with sub-folders "rejected" and "choice" where the photos are stored) instead of "JPG-Original" (where the corresponding destination photos are stored directly without any sub-folders) in the command quoted above (exiftool -tagsfromfile %-:1dJPG/%f.%e -i JPG -ext JPG -r DIR) I get the error message
Warning: Error opening file - I:/JPG/DSC08840.JPG

Greetings, Thomas

Phil Harvey

Hi Thomas,

If you could provide the full path of the source and destination image, maybe I can understand exactly what you are trying to do.

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

Thomas

#9
Hi, Phil,

for testing I have a couple of jpg files stored in the directories
I:\Test\2007 VacationFrenchAtlanticOceanCoast\JPG\rejected and
I:\Test\2007 VacationFrenchAtlanticOceanCoast\JPG\choice as well as
I:\Test\2007 VacationTuscany\JPG\rejected and
I:\Test\2007 VacationTuscany\JPG\choice.
The jpg backup files (with exactly the same names) are stored in
I:\Test\2007 VacationFrenchAtlanticOceanCoast\JPG-Original and
I:\Test\2007 VacationTuscany\JPG-Original

I'd like to copy tags from the "rejected" and "choice" folders to the corresponding "JPG-Original" folders. Here, I used the command
exiftool -tagsfromfile %-:2dJPG-Original/%f.%e -i JPG-Original -ext JPG -r I:\Test.
Exiftool updated the files in the "rejected" and "choice" folders using the old tags from the "JPG-Original" folders which is the wrong "direction" of the copying I intended.
exiftool -tagsfromfile %-:2dJPG/%f.%e -i JPG -ext JPG -r I:\Test results in warnings of the type of Warning: Error opening file - I:/Test/JPG/DSC08813.JPG

At the end (I am confused...) I tried:
exiftool -tagsfromfile %-:1dchoice/%f.%e -i JPG -ext JPG -r %-:2dJPG-Original/%f.%e I:\Test and
exiftool -tagsfromfile %-:1dchoice/%f.%e -i JPG-Original -ext JPG -r %-:2dJPG-Original/%f.%e I:\Test.
The second command only seems to copy from "choice" to "choice" folders with (plausible) warnings for those files stored in the "rejected" folders
File not found: %-:2dJPG-Original/%f.%e
Warning: Error opening file - I:/Test/2007 VacationFrenchAtlanticOceanCoast/JPG/choice/DSC08813.JPG
...

The first command has no effect with warnings of the same type for all files as the destination folder "JPG" is excluded by the -i option.
Hm, what do you think?

Greeting, Thomas

Phil Harvey

Hi Thomas,

Quote from: Thomas on October 23, 2012, 03:14:42 PM
I'd like to copy tags from the "rejected" and "choice" folders to the corresponding "JPG-Original" folders.

Try this: exiftool -tagsfromfile %-:1d/JPG/rejected/%f.%e -ext JPG -r I:/Test

This will copy the metadata just from the rejected images and will give lots of warnings for images which don't have a "rejected" counterpart.

You will need to repeat this command for the "choice" images.

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

Thomas

 :)

Hi, Phil,

I tested the command and it worked as you said. Thanks a lot!  :)  :)
This makes archiving so much easier!

Greetings, Thomas