ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: aaronhui on January 28, 2024, 04:24:46 PM

Title: Copying all metadata from files in one folder and subfolders to another parallel
Post by: aaronhui on January 28, 2024, 04:24:46 PM
I have JPG images from taking photos with a phone that has full metadata values.
These files are in a folder structure such as:
L:\Photos\file1.jpg
L:\Photos\file2.jpg
L:\Photos\Folder1\file1.jpg
L:\Photos\Folder1\file2.jpg

I've compressed a copy of each file using FFMPEG with the same folder structure except that the root folder is: L:\Photos Compressed. FFMPEG does not copy the metadata, so that's where ExifTool comes in.

I have new compressed files in this folder:
L:\Photos Compressed\file1.jpg
L:\Photos Compressed\file2.jpg
L:\Photos Compressed\Folder1\file1.jpg
L:\Photos Compressed\Folder1\file2.jpg

I want to now copy the metadata from the original source folder into the target folder for each file so they now have identical metadata as their original. And maybe add a keyword saying "Resized", but this doesn't matter.

I assume there is a single Exif command that can achieve this. Before, I had my script do each file one at a time but this method was not efficient.

I want to use the Windows ExifTool.exe binary and the command line to achieve this.
I assume it has something to do with a combination of the parameters: -tagsfromfile @ -r -all:all -overwrite_original perhaps %d %f %e but I can't seem to make this work. I searched the forums and Googled for help to no avail. (ChatGPT was also not helpful as usual)

Can you help with this please?

Thank you.
Title: Re: Copying all metadata from files in one folder and subfolders to another parallel
Post by: Phil Harvey on January 28, 2024, 04:32:23 PM
Try something like this:

1. Change directories to "L:\Photos Compressed".

cd L:
cd "Photos Compressed"


2. Run this command:

exiftool -tagsfromfile L:\Photos\%d%f.%e -all:all -subject=Resized -ext jpg -r .

This should copy all standard metadata from the "Photos" files to the JPG files in the "Photos Compressed" folder, adding "Resized" as an XMP keyword (the "Subject" tag).

- Phil
Title: Re: Copying all metadata from files in one folder and subfolders to another parallel
Post by: StarGeek on January 28, 2024, 06:58:43 PM
Quote from: Phil Harvey on January 28, 2024, 04:32:23 PMcd L:
cd "Photos Compressed"

Unfortuneately, cd L: doesn't actually change to the L:\ drive.  You would have to type L: by itself to get to the L: drive, then cd to the correct directory.

But the better solution is the /d option
cd /d "L:\Photos Compressed"
Title: Re: Copying all metadata from files in one folder and subfolders to another parallel
Post by: aaronhui on January 28, 2024, 08:21:45 PM
Excellent. Thanks for the answer. It worked.

I was trying to see if specifying the target folder path within the command parameters would work. I believe from your demonstration, the command has to be run from the path of the target, thus the need to change the working folder. I was up all night trying to figure this one out myself.

Thank you for your quick response.

Aaron
Title: Re: Copying all metadata from files in one folder and subfolders to another parallel
Post by: Phil Harvey on January 28, 2024, 09:17:25 PM
Quote from: StarGeek on January 28, 2024, 06:58:43 PMUnfortuneately, cd L: doesn't actually change to the L:\ drive.

Doh.  Silly me.  My DOS days are too far behind me.  :P

Thanks.

- Phil
Title: Re: Copying all metadata from files in one folder and subfolders to another parallel
Post by: Phil Harvey on January 28, 2024, 09:19:47 PM
Quote from: aaronhui on January 28, 2024, 08:21:45 PMI was trying to see if specifying the target folder path within the command parameters would work.

This could work, but is trickier because you would need to remove this part of the path from the destination by using some of the more advanced %d features.

- Phil