imagetagsmetadataexiftool

How to batch copy metadata from source images to target images with exiftool?


The images are located in folders inside C:/photo.

I have original images and compressed images inside its subfolders and itself.

Here is a example of how the images are organized:

C:/photo/photo1.jpg
C:/photo/photo1_compressed.jpg
C:/photo/folder1/photo2.jpg
C:/photo/folder1/photo2_compressed.jpg
C:/photo/folder1/photo3.jpg
C:/photo/folder1/photo3_compressed.jpg
C:/photo/folder2/photo4.jpg
C:/photo/folder2/photo4_compressed.jpg
C:/photo/folder2/folder3/photo5.jpg
C:/photo/folder2/folder3/photo5_compressed.jpg

Images with suffix _compressed are compressed version of original images with the same name but without the suffix.

How could I use exiftool to copy the metadata from original images to its compressed counterpart, recursively? What about just copying just one tag or a couple of selected tags?


Solution

  • Your command would be:
    exiftool -if "$Filename=~/_compressed/i" -r -TagsFromFile %d%-.11f.%e -All:All C:\photo

    This command will process the files in C:\photo, check to make sure that _compressed is in the name, and copy all tags from the file with the same name minus 11 characters from the end of the file's basename.

    Because you want to recurse, you cannot use a wildcard to only process the compressed files (see Exiftool Common Mistake #2 and the -r (-recurse) option).

    If you want to only copy specific tags, you would replace -All:All with -TAG1 -TAG2-TAGn, replacing TAG# with the actual tag names.

    This command will not copy some tags like ICC_Profile. You can copy color related tags by adding -ColorSpaceTags after the -TagsFromFile option.

    This command creates backup files. Add -overwrite_original to suppress the creation of backup files. If this command is run under Unix/Mac, reverse any double/single quotes to avoid bash interpretation.