Batch processing of specific files

Started by Joanna Carter, June 12, 2021, 08:45:22 AM

Previous topic - Next topic

Joanna Carter

Greetings

I just want to clarify if I can run a command over a list of source files to their correspondingly named XMP files.

I have an existing, working, list of arguments for one file...


  "-all=
  --xmp:all
  -tagsFromFile
  /Users/joannacarter/Pictures/DxO Beta/_JNA0004.NEF
  -all
  -filetype>SidecarForExtension
  -mimetype>format
  -mwg:keywords=Nounours
  -mwg:keywords=Didier
  -xmp-mwg-kw:hierarchicalkeywords={keyword=Nounours}
  -xmp-mwg-kw:hierarchicalkeywords={keyword=Nounours,children={keyword=Didier}}
  -xmp-lr:hierarchicalsubject=Nounours
  -xmp-lr:hierarchicalsubject=Nounours|Didier
  /Users/joannacarter/Pictures/DxO Beta/_JNA0004.xmp


What I could like to be able to do is to specify the list of source files (I cannot use an args file as the filenames are generated from Swift code)


  -all=
  --xmp:all
  -tagsFromFile
  /Users/joannacarter/Pictures/TestImages/_JNA0004.NEF
  /Users/joannacarter/Pictures/OtherImages/_JNA0124.NEF
  /Users/joannacarter/Pictures/MyImages/_JNA0067.NEF
  // ... etc
  -all
  -filetype>SidecarForExtension
  -mimetype>format
  -mwg:keywords=Nounours
  -mwg:keywords=Didier
  -xmp-mwg-kw:hierarchicalkeywords={keyword=Nounours}
  -xmp-mwg-kw:hierarchicalkeywords={keyword=Nounours,children={keyword=Didier}}
  -xmp-lr:hierarchicalsubject=Nounours
  -xmp-lr:hierarchicalsubject=Nounours|Didier
  %d%f.xmp // representing the original filename with an XMP extension


Is this possible?

Phil Harvey

It is done using the -srcfile option, like this:

-all=
--xmp:all
-tagsFromFile
@
-all
-filetype>SidecarForExtension
-mimetype>format
-mwg:keywords=Nounours
-mwg:keywords=Didier
-xmp-mwg-kw:hierarchicalkeywords={keyword=Nounours}
-xmp-mwg-kw:hierarchicalkeywords={keyword=Nounours,children={keyword=Didier}}
-xmp-lr:hierarchicalsubject=Nounours
-xmp-lr:hierarchicalsubject=Nounours|Didier
-srcfile
%d%f.xmp
/Users/joannacarter/Pictures/TestImages/_JNA0004.NEF
/Users/joannacarter/Pictures/OtherImages/_JNA0124.NEF
/Users/joannacarter/Pictures/MyImages/_JNA0067.NEF
// ... etc


The -srcfile option can be confusing.  I suggest reading the documentation so you understand what it is doing.

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

Joanna Carter

Quote from: Phil Harvey on June 12, 2021, 09:58:19 PM
It is done using the -srcfile option, like this:

Thank you, that's just what I needed.

Quote from: Phil Harvey on June 12, 2021, 09:58:19 PM
The -srcfile option can be confusing.  I suggest reading the documentation so you understand what it is doing.

I did read it several (many) times and still couldn't figure out which order the tags needed to go in. Unless I've missed it, the ordering of tags doesn't seem to be covered.

Oh, and why does this tag...


<rdf:Description rdf:about=''
  xmlns:GettyImagesGIFT='http://xmp.gettyimages.com/gift/1.0/'>
  <GettyImagesGIFT:OriginalFilename>IMG_1842.CR2</GettyImagesGIFT:OriginalFilename>
</rdf:Description>


... get added to the XMP files?

Joanna Carter

Just pushing things a bit further...

If I wanted two update both raw files and their XMP sidecars at the same time, is this possible?


-preserve
-ignoreMinorErrors
-overwrite_original_in_place
-mwg:keywords=Nounours
-mwg:keywords=Didier
-xmp-mwg-kw:hierarchicalkeywords={keyword=Nounours}
-xmp-mwg-kw:hierarchicalkeywords={keyword=Nounours,children={keyword=Didier}}
-xmp-lr:hierarchicalsubject=Nounours
-xmp-lr:hierarchicalsubject=Nounours|Didier
/Users/joannacarter/Pictures/TestImages/_JNA0004.NEF
/Users/joannacarter/Pictures/OtherImages/_JNA0124.NEF
/Users/joannacarter/Pictures/MyImages/_JNA0067.NEF

-execute // is this necessary?

-all=
--xmp:all
-tagsFromFile
@
-all
-filetype>SidecarForExtension
-mimetype>format
-mwg:keywords=Nounours
-mwg:keywords=Didier
-xmp-mwg-kw:hierarchicalkeywords={keyword=Nounours}
-xmp-mwg-kw:hierarchicalkeywords={keyword=Nounours,children={keyword=Didier}}
-xmp-lr:hierarchicalsubject=Nounours
-xmp-lr:hierarchicalsubject=Nounours|Didier
-srcfile %d%f.xmp
/Users/joannacarter/Pictures/TestImages/_JNA0004.NEF
/Users/joannacarter/Pictures/OtherImages/_JNA0124.NEF
/Users/joannacarter/Pictures/MyImages/_JNA0067.NEF


I tried it without the -execute and it didn't play.

Also, is there a way to avoid repeating the list of files?

Joanna Carter

RE: my last post...

I realise now that not all of the files for the first part of the command will be in the second. This is because some of the files in the first part will not be RAW files and will not need an XMP file writing.

I have written code that handles the two lists but it has meant introducing an -execute tag between the two parts.

My question remains - is it possible to avoid this given what I want to do? I can quite understand if it isn't.

Phil Harvey

Hi Joanna,


You can delete tags, assign tags and copy tags (from one or more files) all in the same command.

You asked why the GettyImagesGIFT OriginalFilename is being written.  There must be a tag called OriginalFilename that is being copied to the XMP file.  Since XMP files can's store EXIF OriginalFilename, the XMP version is being written.

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

Joanna Carter

Quote from: Phil Harvey on June 13, 2021, 04:04:51 PM
You can delete tags, assign tags and copy tags (from one or more files) all in the same command.

But does issuing an -execute count as part of one command, or does it effectively make it two?

I have an async monitoring process watching for file changes and was hoping to minimise the number of triggers. In your opinion, what is the better strategy?

Thanks.

Joanna

Phil Harvey

-execute effectively divides the command line into separate commands.  They execute independently.  The only advantage is that you avoid the overhead of loading the exiftool app each time.

Processing files fewer times is always better.

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