adding keywords and rating depending on whether file copies are in subfolders

Started by baudri, January 17, 2017, 06:05:18 AM

Previous topic - Next topic

baudri

Hello all,

I did not really find a solution to my "problem": I have my jpegs organized like that: each Event (like a holiday) has a folder. In that folder I have subfolders for the very nice jpegs or for jpegs of Beaches and so on. In the subfolders there are copies of the jpegs.
Now, I saw the great possibilities of a keyword-based organizer-tool (Adobe Photoshop Elements Organizer) which seems to help me find my pictures. But this tool does not allow copies of the same file. Hence, I want to get rid of the subfolders, but do not loose the information that the pictures therein where "nice" or e.g. "Beaches".

Is this (easily) possible with ExifTool?

My Idea would be to go through all pictures in subfolder "nice", find their original in the upper folder and add the rating"4stars". I would do the same for the other subfolders, but then I would like to add a special keyword (is this the correct name?), depending on the subfolder (without overwriting previous ones). The solution does not necessary have to be fully automatic, since I do want to convert the Folder structure only once  ;). When finished, I would like to delete the subfolders. There are not too much subfolders in each folder.

I do know some basic Python and Bash-Scripting, but I am not sure, which is best suited and how it would be best to start. So, if someone could please point me to a starting point or even to an already existing script or program, that would be great. I work under Windows, but do also have a (virtual) Linux.

Many thanks in advance!
Uwe

Phil Harvey

Hi Uwe,

Adding keywords based on folder name is easy, but it sounds like you want to do more than this.  If you give me an example of your file hierarchy and the exact metadata you want to add to a file then I can give an example command.

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

baudri

Hi Phil,

many thanks for the immediate reply. I will try to describe my folder structure better:

Lets assume I have

  • one main-folder 'main', with 5 pictures in it: house, joe, mountain, party, ball.
  • In subfolder 'sub1' are copies of house, joe
  • in subfolder2 'sub2' are copies of joe, party, ball
  • in subfolder3 'nice' are copies of joe, house, mountain

The result should be, that the folder 'main' still contains all 5 pictures and that the pictures have the following additional metadata:

house: Keywords: sub1-keyword; Rating=4
joe: Keywords: sub1-keyword,sub2-keyword; Rating=4
mountain: Rating=4
party: Keywords sub2-keyword
ball: Keywords sub2-keyword

Is the purpose clear? After that I want to delete the three subfolders and would not loose both pictures and information. So, all pictures in a subfolder should get a keyword (or rating): not the pictures in the subfolder, but in the main folder.

If there is some information still missing, I will be more than happy to provide it.

Thanks,
Uwe

Phil Harvey

Hi Uwe,

Thanks.

This command will do exactly what you asked:

exiftool -srcfile %-:1d/%f.%e "-subject+<${directory;s(.*/)();/nice/ and undef $_}-keyword" "-rating<${directory;$_=/nice/ ? 4 : undef}" -r DIR

Where DIR is the name of the top-level directory.  This command will process many directories at once if you point it to the root directory containing multiple image folders.  Note that the command will generate many "File not found" warnings when images don't have a copy in the parent directory (which will happen for the main folder), and "Tag not defined" errors for images that are processed which don't generate a keyword or rating.  Note also that I am writing keywords to XMP:Subject and rating to XMP:Rating which may or may not be what you wanted.

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

baudri

WOW! I did a short test and the command did exactly what I wished! :). It works like a charm. Many many thanks for the fast help and the great ExifTool!

Uwe