1

I have a bunch of PNGs, which were sourced from scanned photographs with a creative-historical context. I converted them to JPGs so that I could write the DateTimeOriginal tag to them using ExifTool through ExifGui. I created DateTimeOriginal tags for the PNGs from the preexisting FileModifyDate tags en masse.

I can successfully copy metadata from PNGs to JPGs with DateTimeOriginal intact from a PNG file to one JPG file at a time using the following command.

exiftool -tagsfromfile file.png file.jpg

However, I want to copy metadata from PNGs to JPGs en masse.

I am an amateur photographer that uses ExifGui primarily for giving files DateTimeOriginal tags, so I don't have a good grasp on what most commands do. I have tried looking elsewhere, but I have not found answers and I am not patient enough to look through the documentation. Is there a way to copy metadata from a group of PNGs to JPGs if only their file extensions are different using variables or similar?

  • I'm voting to close this question as off-topic because it mentions nothing about actually making photographs. The source of the PNGs could be anything other than photos. – Michael C Sep 12 '18 at 22:44
  • 1
    By that reasoning, any question asking about non-raw formats should also be off topic because the source of any other format, such as JPGs, may also be anything other than photos. This question is valid because metadata manipulation is a common photographic task. The answer applies to copying metadata from any format of interest, such as RAW, TIF, and XMP. – xiota Sep 13 '18 at 1:24
  • @xiota The comment above does not say that any question about PNGs is off topic. It says that this question makes no mention of the source of the PNGs being photographs. Perhaps it is a subtle difference, but it is a significant difference in light of previous discussions here about when image processing questions are and are not on topic. Bottom line, it needs to have some application to taking photographs to be on topic here. – Michael C Sep 13 '18 at 4:42
  • The source of the PNGs is not relevant to the answer. You can presume them to be photographs or not, and the answer will be the same. Manipulating metadata is still relevant to photographers, and photographers would still be expected to have expertise on the matter regardless of the source of the images. – xiota Sep 13 '18 at 4:54
  • 1
    Earplugs, shoes, and hard drive formats are on topic, but image metadata is not? – xiota Sep 13 '18 at 5:06
3

The command you would use would be:
exiftool -tagsfromfile %d%f.PNG -ext JPG DIR

This assumes that the files are in the same directory and have the same base filename. This command creates backup files. Add -overwrite_original to suppress the creation of backup files. Add -r to recurse into subdirectories.

This command looks at every jpg in DIR and looks for a matching PNG file to copy from. %d is the file path (including the trailing slash), change this if the png files are in a different directory. The %f is the base filename not including the extension. -ext jpg tells exiftool to ignore any file that isn't a jpg, so it doesn't try to copy the tags from the png files back onto itself.

  • I read the man page and still don't understand how the % references work. For instance, how to copy tags from file01.jpg to file02.jpg, file03.jpg, etc? – xiota Sep 13 '18 at 2:15
  • @xiota your particular case is a poor fit for the % references. OP's case, where all the PNG files have the same basename as their corresponding JPEG file, is where % references shine. In your case, you could use shell scripting to iterate through. But in OP's case, StarGeek's answer is equivalent to exiftool -tagsfromfile file01.jpg file01.png; exiftool -tagsfromfile file02.jpg file02.png... etc. – scottbb Sep 13 '18 at 2:31
  • 1
    @xiota %d, %f, and %e refer to the directory, file basename, and file extension of the input file. So you can't directly split a file basename into parts, increment based on backrefs, etc., like you can do with full-fledged shell scripting. – scottbb Sep 13 '18 at 2:46
  • 1
    It's also very important to remember that the %d and %f (as well as related %e, %c) are limited in scope. They can only be used to represent a filename that exiftool is reading or writing. They can't be used to copy to a tag name. For example, if you want to copy the filename into the description, you can't use '-Description<%f' In such a case, you have to use the tag that represents the data you want, such as '-Description<Filename'. See the -w option for details. – StarGeek Sep 13 '18 at 3:22
  • Thanks StarGreek! The command worked perfectly. Now its less of a hassle to tag my images. – Nebraska Mudstone Sep 13 '18 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.