Export meta data of one set of photos, then overwrite other photos' data

Started by Idiotfool, May 28, 2017, 01:27:35 AM

Previous topic - Next topic

Idiotfool

Greetings! Exiftool looks like it will be the perfect tool for me. I'm using photoshop to do some batch manipulations, but meta-data of the photos I've loaded in during the batch process is not preserved. I'd like to use Exiftool to download out the existing files (which are named according to the default camera settings, like "DSC_0001") to the edited files (which are simply numerically named, like "1.jpg"). When I manually rename the edited files, I have successfully used the GUI to transpose one set onto their like-named edited photos, but this isn't ideal.

I did get the tool to export each original photo's meta data as a text file (named the same as the photo). I couldn't work out how to then take that data and apply it to another set of photos, whether they were identically named or not.

I've also been trying to puzzle over how I could set the exiftool to be pre-formatted to export all meta data loaded in to a single csv file. While not necessary to have this as a single file, it would be more straightforward for me. I'd then want to use the csv to overwrite the meta data of the edited files, but haven't had luck working that out, either.

Any thoughts on this? I'm assuming I need duplicate exiftools, with different parameters called out, I just don't know what, specifically, I need to add.

Thanks!

Phil Harvey

There are many ways to do this, but it would be difficult going through a CSV file because the file names are different.

I would suggest copying the metadata directly from the original to edited files, like this:

exiftool -tagsfromfile SRCDIR/DSC_%f.JPG -all:all -tagsfromfile SRCDIR/DSC_0%f.JPG -all:all -tagsfromfile SRCDIR/DSC_00%f.JPG -all:all -tagsfromfile SRCDIR/DSC_000%f.JPG -all:all DSTDIR

Here, SRCDIR is the directory of the original images, and DSTDIR is the directory of the edited images.  I am copying tags as -all:all to preserve their original locations, and have used four -tagsFromFile options to account for the differences in the number of digits in the edited file names.

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

Idiotfool

Hi, Phil. Thank you much for the support.

A single csv file for me might have been useful because I could simply embed the exif information I wanted as a text variable when I do my batch photoshop editing. Then, there'd be no question as to what settings were used. If I could then edit and use the csv to overwrite the metadata on the final images, that'd be a bonus.

I was able to get your suggested command line to work. Is there any way to prevent the original image from being written, to speed up the process?

Thanks!

Phil Harvey

The original image should not be written.  (unless DSTDIR is the same as SRCDIR, in which case you should specify a pattern instead of a directory name to match only edited images)

Could you do what you want with separate sidecar files instead of a single csv file?

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

Idiotfool

Phil,

Sorry for the confusion. I saw that the default setting is to preserve the edited document as a .original file. I added the -overwrite_original command, but it doesn't appear to run any more quickly. I'll never run more than 999 photos at a time, so I simplified the command code.

exiftool -tagsfromfile SOURCE/DSC_0%f.JPG -all:all -tagsfromfile SOURCE/DSC_00%f.JPG -all:all -tagsfromfile SOURCE/DSC_000%f.JPG -all:all EDITED -overwrite_original

where "Source" is the source folder and edited is the photoshop generated and edited file folder.

Regarding your question - no, I can't easily do what I want with individual, sideloaded csv files. I could, potentially, set up a macro in excel to pull in all of the data from a folder, but I was hoping for a single process. Any thoughts on a single csv with all data?

Thanks!

Phil Harvey

The -overwrite_original doesn't save any time.

I don't know exactly what you want to do with the CSV.  Can you give me simple workflow example?

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

Idiotfool

Phil,

In photoshop, you can create data-driven, batch processed images using csv or text files. In my case, I am taking the unedited images, importing them into photoshop and, using a CSV file, create a header for all of my documents (specimen IDs, test type, etc.). I could add changing variables that indicate the f-stop, ISO and other values into the header if I had a single csv with the exif data.

If you're not familiar with batch processing in photoshop, this video may prove useful: https://www.youtube.com/watch?v=i9Ms34nYRFI

In my head, I see myself:

-Extracting the meta-data of the images into a single csv file.
-Using that csv file, I would incorporate it into the document I have already created for my batch processes.
-During the batch process, the relevant information (ISO, f-stop, and exposure time) would be parsed into photoshop and would be incorporated into the header I designed.

Upon completion of the process, I would do the final overwrite of the new files' metadata.

Why would I need the information in the header, if it's part of the meta data, you may ask. The reason is that I work in a test laboratory and the photography is done per our customer's requirements. They typically like to embed our images into presentations, as-is, and having this sort of data available in the presentation (and embedded as part of our process) may be seen as a benefit by our customers.




Does -overwrite_original not save any time because exiftool still creates a temp file, then simply saves the temp file over the original? Is there any command I can input to speed the process up?

Thank you!

Phil Harvey

Yes, ExifTool always creates a temporary file so the original is not damaged in the event of a system shutdown.

The trick with using a CSV file is that ExifTool requires a SourceFile column which gives the name of the file, and if you want to write the metadata to a file with a different name then you must change the SourceFile entry.

However, you could get around this by using hard links to emulate a duplicate set of original files with the same names as the edited images.  The steps would be:

1. Change to the directory of the original images:

cd SRCDIR

2. Create hard links in a temporary directory with names corresponding to the edited images:

exiftool "-hardlink<../tmp/${filename;s/DSC_0*//}" .

3. Change to the temporary directory:

cd ../tmp

4. Export information from the original images to a CSV file (which I write to the directory of the edited images, DSTDIR):

exiftool -csv . -TAG1 -TAG2 ... > DSTDIR/out.csv

(where TAG1, TAG2, ... are the list of tags you want in the CSV file)

5. edit DSTDIR/out.csv as required

6. Change to the directory of the edited images:

cd DSTDIR

7. Import information from the CSV into the edited images:

exiftool -csv=out.csv .

8. Delete the SRCDIR/../tmp temporary directory containing the hard links.

All done.

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

Idiotfool

Phil,

Thank you for this. I was able to generate a csv file and import, though I had some difficulty getting hardlink to work, I was able to manually change the image IDs without any real issue. Silly question, but when I changed directories through the command prompt, if I didn't have exiftool in every folder I wanted to run a process in, there was an error. Just to confirm - I need to have exiftool in every location, correct?

With respect to the csv file, I came across an issue the other day in experimenting where the camera wasn't reset before photos were taken. I started with DSC_0007, which would not overwrite to the corresponding, edited image of "1.jpg". Of course, the meta data for DSC_0007 DID overwrite that of the edited/generated "7.jpg", which isn't what I wanted to have happen.

Using csv files, I can avoid issues like this by simply changing the image list to always start with 1, no matter what the DSC_00 value was. I exported the csv with the -all:all tag, then successfully imported this into my edited folder. It was successful, but I'd like to confirm that there aren't any issues that you would anticipate with doing this.

Thanks, again.

Phil Harvey

Quote from: Idiotfool on May 31, 2017, 12:40:53 PM
Just to confirm - I need to have exiftool in every location, correct?

No.  You just need the ExifTool directory to be in your PATH.

QuoteUsing csv files, I can avoid issues like this by simply changing the image list to always start with 1, no matter what the DSC_00 value was. I exported the csv with the -all:all tag, then successfully imported this into my edited folder. It was successful, but I'd like to confirm that there aren't any issues that you would anticipate with doing this.

This sounds OK.

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

StarGeek

You can move exiftool to "c:\Windows" folder and it will be available everywhere.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Idiotfool

Thanks, all.

I have been successfully using the tool to update various photos with great success. I decided to try to make a batch file with the code and have run into some snags. A lot of my photos are on a shared network drive, with shortcuts to the network folders, rather than any mapped folders, so that paths work for all users. When I manually open a command line, everything works (Windows seems to automatically map the drive), but when I try to do so with a batch file, it doesn't work. The command prompt indicates it won't work with UNC files and attempts to read from the windows drive.

Any suggestions or workarounds for this?

Thanks!

StarGeek

Can you give an example command and the exact output?  You can add |clip to the end of the command to automatically copy output to the clipboard for easy pasting here.

I just tested a simple bat command to a file on my media server and it processed the file without problem.

Are you doubling all percent signs (%) in the bat file?

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Idiotfool

Sure. I manually run:

exiftool –csv . –all:all > out.csv

As a batch file, I try:

exiftool -csv . -all:all ^> out.csv

If I run this in a mapped network drive (V:\Photos), everything runs fine. If I run an unmapped network drive (\\Network\Photos), the command line craps out because it tells me that \\Network\Photos is a UNC and it won't run it, then attempts to run the command line in C:\Windows.  See this error as an analagous issue:



StarGeek

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Idiotfool

That's correct, Stargeek. I was hoping someone here knew a batch file workaround for this sort of thing.

Thanks, again.