Mac: Copy -makernotes Capture One Session from Capture to Output?

Started by Frediko, October 09, 2019, 12:59:45 PM

Previous topic - Next topic

Frediko

Hi,

as Capture One doesn't "copy" all exif data during the processing (from raw to jpeg) I'd like to ask exiftool to do so. Especially the -makernotes I'm interested in. I'm working on a Mac (Mojave), using Capture One Pro 12 and exiftool in version 11.59.

I was able to copy and paste (rather than typing) this code so far, might be not each single line of code is needed :-)


tell application "Capture One 12"
set selectedVariants to get selected variants
repeat with i from 1 to number of selected variants
set this_item to item i of selectedVariants
set theID to name of (parent image of this_item)
set storedPath to path of (parent image of this_item)

set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set itemCount to (count text items of storedPath)
set lastItem to the last text item of storedPath
set itemCount to itemCount - 2 -- bei Pfad zu einem Ordner
set EventPath to text 1 thru text item itemCount of storedPath

set AppleScript's text item delimiters to "."
set itemCount to (count text items of theID)
set lastItem to the last text item of theID
set itemCount to itemCount - 1
set filesname to text 1 thru text item itemCount of theID

set AppleScript's text item delimiters to "/"


do shell script "/usr/local/bin/exiftool -tagsfromfile " & quoted form of storedPath & " -makernotes " & quoted form of EventPath & "/output/" & filesname & "-C1.jpg"
end repeat
end tell


This code is stored as a .scpt file and got copied to the capture one scripts area in the Mac library. This script is working but by far not perfect and is most likely very complicated.

The "-C1.jpg" at the end of the do shell script is due to my internal name convention.

What I'd like to achieve is:

1.) The script should copy the -makernotes of a processed raw-file (in my case an orf-file of Olympus) into the resulting e.g. jpeg file automatically after the processing - there is a method to call a script "automatically" after processing, so this is not the main problem.
2.) This should not only work with the first processed variant of a file but with all variants. Capture one normally adds numbers like 1, 2, etc to subsequent processed files with the "same" name. However, as far as I understand, Exiftool doesn't support wildcards here (using -tagsfromfile)
3.) Capture One Sessions normally contain the "to be processed files" in a directory called ../parent-dir/capture and shifts the "processed files" to a directory called ../parent-dir/output.

Any hints to make this script working in the way I'd like to use it? Thanks in advance



Phil Harvey

First, if you are copying MakerNotes, you should also copy Make and Model.

To handle the variants, you would need to remove the file suffix in the -tagsfromfile argument to make this work.  ExifTool provides a method to use or ignore a fixed number of characters from a file name, which may allow you to do this depending on the naming convention.  See the -w option documentation for details.

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

Frediko

I'll try this out and thanks. Not only for the fast answer but for the whole tool as such. It is really excellent.

Frediko

make and model got added.

I think you were referring to format codes like e.g. %f and %c in the -w option documentation, right? As I was not able to get the script run maybe I did not understand correctly what you meant with "to remove the file suffix"?

What I tried out was:
.) deleting the extension (.orf) from the source file (error message: file does not exist)
.) removing the extension (.jpg) in the destination file (file not found)
.) changing the destination's file name to variants of format codes (the error message was like the file /path/%f.. was not found)
.) different combinations of all the above

Non of the above was successful. I believe I wasn't able to use the %f and %c in a way the script understands it as a code instead of a part of the name.

Do you have any further suggestions?

Phil Harvey

Quote from: Frediko on October 10, 2019, 01:50:59 AM
I did not understand correctly what you meant with "to remove the file suffix"?

I meant, for example, if the suffix is 3 characters then you would use %-.3f, or if the file name without suffix was always 8 characters, you could use %8f.

- 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

Here are some examples of what Phil is saying.  In your above code you use the file name -C1.jpg.  Assuming the number 1 is the number that Capture One is adding, you could use %2f.orf to use -C.orf as the source file name in the case that all the source files were originally just 2 characters.  Or if all the processed files had a number added, you could use %-.1f.orf to remove the last character from the jpg file name, not counting the extension.
* 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).

Frediko

Thanks for the answers. "-C1.jpg" is (currently at least, maybe I'll rethink this) my convention to distinguish out of camera jpegs from capture one processed jpegs. The later have -C1 added. The filenames I'm used to use do not have a fixed number of characters as they contain the "-model" info. In my workflow they get renamed in an autoingest process in photo mechanics.

the source file name could be like [date]-[time]-[model]-[number].orf if this is an Olympus model. Could be a .cr2 file in case of Canon etc (those files are stored in the "capture" path of a capture one session). The first time I process a file in Capture One the output would be [date]-[time]-[model]-[number]-C1.jpg (stored in the "output" path of a capture one session). Then maybe I'd chance some parameters in the raw-processing and process the same raw date a second time. The output would be stored as [date]-[time]-[model]-[number]-C1 1.jpg.

The -tagsfromfile source would be [date]-[time]-[model]-[number].orf  but the destination file would either be [date]-[time]-[model]-[number]-C1.jpg or [date]-[time]-[model]-[number]-C1 1.jpg. Maybe I'll have to use a loop for all jpegs starting with [date]-[time]-[model]-[number]... Or is there a better exiftool method?

Best Manfred




Phil Harvey

Hi Manfred,

You could copy makernotes tags from the source files (in DIR1 and with extension EXT1) to the C1-processed files like this:

exiftool -tagsfromfile DIR1/%-.3f.EXT1 -make -model -makernotes -tagsfromfile DIR1/%-.5f.EXT1 -make -model -makernotes DIR2

Where DIR2 contains the files ending in "-C1.jpg" and "-C1 X.jpg".

The command tries to find source files with the same name minus the last 3 and 5 characters.

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

Frediko

Thank you again, this looks very promissing. I'll try it out...

Frediko

works quite as planned, not exactly but does what it should do. Thank you very much again.


tell application "Capture One 12"

set selectedVariants to get selected variants --the variants selected in Capture One

repeat with i from 1 to number of selected variants --loop thru all variants
set ThisItem to item i of selectedVariants --the current item processed
set SrcFileName to name of (parent image of ThisItem) --Source File Name including path
set SrcFilePath to path of (parent image of ThisItem) --Path to Source File

--Identify the parent directory of the source's directory
--'Capture' as well as 'Output are in the same parent directory

set AppleScript's text item delimiters to "." --The file's extension is seperated by a "."
set itemCount to (count text items of SrcFilePath) --should be two
set FileExt to the last text item of SrcFilePath --The file's extension

set AppleScript's text item delimiters to "/" --The directories are seperated by a "/"
set itemCount to (count text items of SrcFilePath) --should be some
set SrcFile to the last text item of SrcFilePath --the source file without path
set itemCount to itemCount - 2 -- bei Pfad zu einem Ordner
set parentpath to text 1 thru text item itemCount of SrcFilePath

set sourcepath to parentpath & "/capture"
set destpath to parentpath & "/output"

do shell script "/usr/local/bin/exiftool -tagsfromfile " & quoted form of sourcepath & "/%-.3f." & FileExt & " -make -model -makernotes -tagsfromfile " & quoted form of sourcepath & "/%-.5f." & FileExt & " -make -model -makernotes " & quoted form of destpath & ""

end repeat --end of loop
end tell