Adding filename to IPTC keyword field in subfolders

Started by Archive, May 12, 2010, 08:54:40 AM

Previous topic - Next topic

Archive

[Originally posted by salviati on 2009-09-13 20:13:46-07]

For several weeks I have been trying to find a way to add an image file's name to the keyword field of that image.  For example, adding a keyword tag called 'IMG_0123.JPG' or 'IMAGE_0123.CR2' to an image file with the same name.  I am trying to do this so that I can later rename my files when they are imported into Lightroom, while still maintaining a reference to the original file on a separate drive.

 

So far, Friedemann Schmidt was kind enough to provide me with the following code, which partially does what I'm looking for:

Code:
c:\exiftool "-iptc:keywords+<$filename" "-xmp:subject+<$filename" -if "not $iptc:keywords=~/$filename/" *.jpg

This command works for JPG files contained in the folder I launch this from.  However, my file structure has several levels, for example: S:/DCIM/IMG.../...CR2.  I've tried modifying the above code with a -r at the end, but that didn't work.  So my questions are:

1) How can I get this command to work within all the sub-directories of my file structure?

2) Can this code me modified to apply to JPG, CR2, and RAW filetypes at the same time?

3) Will the above code modify or delete any unintentional EXIF or IPTC fields other than for Keywords?

4) Can this command be modified to not create the "...jpg_original" file (since I already have the originals elsewhere)?

Thank you very much for this great program and for your assistance.

Archive

[Originally posted by exiftool on 2009-09-13 22:43:30-07]

I'll try to answer your questions:

1+2) use "exiftool -r DIR ..." to process all files in DIR and its
subdirectories.  This will process any file that is writable by
exiftool.

3) The above command will only add a keyword to IPTC.  It won't
modify any other EXIF or IPTC.

4) You can use the -overwrite_original option to prevent the
_original files from being saved.

- Phil

Archive

[Originally posted by salviati on 2009-09-14 02:08:57-07]

Thank you for the quick reply, Phil.  So I think I almost have it now.  So is this correct if I have exiftool located in the root of the C drive, and my photos are all within the S:/Photos/ folder(with several levels of nested folders)?

Code:
c:\exiftool -r S:\photos\ "-iptc:keywords+<$filename" "-xmp:subject+<$filename" -if "not $iptc:keywords=~/$filename/" -overwrite_original

Is the location of the directory correct, and will it recognize files that are 3+ layers deep?

Archive

[Originally posted by exiftool on 2009-09-14 11:20:50-07]

Yes, this should work.  ExifTool will process all writable files (use
"exiftool -listwf" to see the file extensions of all writable files).
If you want to change the files processed, you can either specify
the extensions you want to process with -ext EXT, or
extensions you want to exclude with --ext EXT, where
EXT is any file extension (case does not matter).

- Phil