News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Shorten up -execute command strings

Started by dwlott, April 15, 2022, 12:18:46 AM

Previous topic - Next topic

dwlott

Hello again,
These command strings work, but it would be better if they were shorter.
What are some good ways of shortening up these command strings? 

In the first string, I am writing the same tag values to multiple files. 
In the second string, I am copying all tags from one file to multiple files. 
I am looking at "-common_args", but am not sure what to do.

Write same tag values to multiple files:
e:\exiftool\exiftool -ext JPG -IPTC:City="Dallas" -IPTC:Province-State="Texas" "e:\exiftool\mySourceFolder\TargetFile1.jpg" -execute -ext JPG -IPTC:City="Dallas" -IPTC:Province-State="Texas" "e:\exiftool\mySourceFolder\TargetFile2.jpg" -execute

Copy all tags from one file to multiple files:
e:\exiftool\exiftool -ext JPG -tagsFromFile "e:\exiftool\mySourceFolder\SourceFile.jpg" -all:all "e:\exiftool\mySourceFolder\TargetFile1.jpg" -execute -ext JPG -tagsFromFile "e:\exiftool\mySourceFolder\SourceFile.jpg" -all:all "e:\exiftool\mySourceFolder\TargetFile2.jpg" -execute

Thank you again for your help. 
      


StarGeek

You can write to multiple files at once.  You don't have to execute after every single file.  You can even mix individual files and directories in the same command

exiftool -ext JPG -IPTC:City="Dallas" -IPTC:Province-State="Texas" "e:\exiftool\mySourceFolder\TargetFile1.jpg" "e:\exiftool\mySourceFolder\TargetFile2.jpg"

exiftool -ext JPG -tagsFromFile "e:\exiftool\mySourceFolder\SourceFile.jpg" -all:all "e:\exiftool\mySourceFolder\TargetFile1.jpg""e:\exiftool\mySourceFolder\TargetFile2.jpg"
* 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).

dwlott

Thank you StarGeek. Your reply on how to shorten my strings is making my work much easier. 

Please help me shorten this command line as well. 
This command string reads multiple files in a source folder and makes .mie sidecar files in a target folder for each file, keeping its original file name before the extension.

e:\exiftool\exiftool -TagsFromFile "e:\mySourceFolder\File1.jpg" -all:all "e:\myTargetFolder\File1.mie" -TagsFromFile "e:\mySourceFolder\File2.jpg" -all:all "e:\myTargetFolder\File2.mie" -TagsFromFile "e:\mySourceFolder\File3.jpg" -all:all "e:\myTargetFolder\File3.mie"

Also, is there an easy way to make sidecar files for all files in a source folder to a target folder?
This was a guess and it didn't work: 
e:\exiftool\exiftool -TagsFromFile "e:\mySourceFolder\*.* -all:all "e:\myTargetFolder\*.mie"



StarGeek

See Example #13 on the Metadata Sidecar Files page.  It's a bit more complicated than #11 and #12 which work in a similar way.  Only a couple changes to make it work for MIE files.

exiftool --ext mie --ext xmp -tagsfromfile @ -All:All -srcfile %d%f.mie -r /path/to/files/

Here I excluded files with an MIE or XMP extension.  In the first case, you don't want to copy the data from an MIE file back into the same file, it's a waste of time.  In the second case, thinks could get messy if you have a RAW file and an XMP sidecar already.  It would try to copy both files into the MIE sidecar.
* 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).

dwlott

Another string shortening question:  This command writes the output files to a common target folder. 
Here is an example of different tag values but all going to the same target.  When I leave off the "-execute" here, the results are different than I expected with each subject field filling with the set "Painting, Doorway, Statue, Stairs". 

This does not work (no "-execute"):
e:\exiftool\exiftool -Subject="Painting" "E:\mySourceFolder\File-01.jpg" -o "E:\myTargetFolder" -Subject="Doorway" "E:\mySourceFolder\File-02.jpg" -o "E:\myTargetFolder" -Subject="Statue" "E:\mySourceFolder\File-03.jpg" -o "E:\myTargetFolder" -Subject="Staircase" "E:\mySourceFolder\File-04.jpg" -o "E:\myTargetFolder"

This works, but what is the best way? Note the common target folder. 
e:\exiftool\exiftool -Subject="Painting" "E:\mySourceFolder\File-01.jpg" -o "E:\myTargetFolder" -execute -Subject="Doorway" "E:\mySourceFolder\File-02.jpg" -o "E:\myTargetFolder" -execute -Subject="Statue" "E:\mySourceFolder\File-03.jpg" -o "E:\myTargetFolder" -execute -Subject="Staircase" "E:\mySourceFolder\File-04.jpg" -o "E:\myTargetFolder" -execute

In a previous example, you pointed out that I could leave off "-execute" from the command string.  In that example it worked, I was able to leave off "-execute" and the command worked with a shorter string. 

Phil Harvey

You can leave off the last execute, and group the common arguments together:

e:\exiftool\exiftool -Subject="Painting" "E:\mySourceFolder\File-01.jpg" -execute -Subject="Doorway" "E:\mySourceFolder\File-02.jpg" -execute -Subject="Statue" "E:\mySourceFolder\File-03.jpg" -execute -Subject="Staircase" "E:\mySourceFolder\File-04.jpg" -common_args -o "E:\myTargetFolder"

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