Hi There
I wonder if some of the clever people on this Forum can help me. I am brand new to Exiftool.
I have around 250,000 + images a mixture of scanned images and images from a variety of digital cameras, which I am try to manage more effectively, a long job!
At present I am working on a series of Scanned Images which were scanned some years ago and given names such as:
1999 - 10 - 06 - In and around Red Rocks, Morrison, Colorado
1999 - 10 - 06 - In and around Red Rocks, Morrison, Colorado_0001
1999 - 10 - 06 - In and around Red Rocks, Morrison, Colorado_0002
1999 - 10 - 06 - In and around Red Rocks, Morrison, Colorado_0003
1999 - 10 - 06 - In and around Red Rocks, Morrison, Colorado_0004
1999 - 10 - 09 - South Park, Fairplay-Engine Room
1999 - 10 - 09 - South Park, Fairplay-Engine Room_0001
1999 - 10 - 09 - South Park, Fairplay-Engine Room_0002
and so on. Some of the file names have sequential numbers and some do not.
I want to use the filenames names as captions, and I want to use an action or batch process to do this. I am using ACDSee Ultimate 2021 to manage and manipulate the images.
Thanks to help from the ACDSEE forum the method that has been suggested is to embed the filenames into IPTC->ObjectName. I can then use ACDSee to create captions.
For those files that have the _nnnn.jpg ending I am using exiftool "-iptc:ObjectName<${filename;s/_....\.jpg//i}" *.jpg which works perfectly. However not surprisingly this does not work for those files that do not have the _nnnn.jpg ending. For these I use exiftool "-iptc:ObjectName<${filename;s/\.jpg//i}" *.jpg which again works but for the _nnnn.jpg files it puts the _nnnn back into IPTC->ObjectName. Whichever order I run the Exiftoll command in the other files with a different naming structure is affected.
Now I know that I could move the two "types" of files into different folders and run the commands separately, but I have 100s of thousand of files so that would be a pain.
I was wondering if there is a way in exiftool to run the first command exiftool "-iptc:ObjectName<${filename;s/_....\.jpg//i}" *.jpg which works on the _nnnn.jpg files but leaves the .jpg in the others, then have a command in Exiftool that goes through the files looking just for the ones that have .jpg in the IPTC->ObjectName and stripping the .jpg out by perhaps temporarily writing the contents of the IPTC->ObjectName into another not used location then writing it back but without the .jpg. Or can I get Exiftool to only apply the 2nd command exiftool "-iptc:ObjectName<${filename;s/\.jpg//i}" *.jpg to those files that do not have _nnnn at the end.
Any assistance would be most gratefully received.
Regards
Michael
Hi Michael,
I think this may be what you want:
exiftool "-iptc:ObjectName<${filename;s/_....\.jpg//i;s/\.jpg//i}" -ext jpg .
- Phil
Phil,
Thank you for your reply. When I tried your suggestion I got the response no file specified, so I tried adding " *.jpg " to the end so the complete command was
exiftool "-iptc:ObjectName<${filename;s/_....\.jpg//i;s/\.jpg//i}" -ext jpg *.jpg and it worked perfectly so thank you very much.
I presume that the addition of the ;s/\.jpg specifies the files that do not have the _nnnn should also be modified, is there a limit as to how many of this type of parameters can be added?
Also what is the purpose of -ext jpg ?
I need to understand what all of the various symbols (like s/ /i etc) in the commands do. I assume that there is a list somewhere?
Again thank you very much for your assistance.
Regards
Michael
Quote from: michaelw on February 12, 2021, 09:51:33 AMThank you for your reply. When I tried your suggestion I got the response no file specified
Did you make sure to include the dot on the end? A dot on the command line indicates the current directory. Using a wildcard works as long as you're not trying to recurse into subdirectories with the
-r (-recurse) option (https://exiftool.org/exiftool_pod.html#r-.--recurse) (see Common Mistake #2 (https://exiftool.org/mistakes.html#M2))
QuoteI presume that the addition of the ;s/\.jpg specifies the files that do not have the _nnnn should also be modified, is there a limit as to how many of this type of parameters can be added?
That part strips off the
.jpg from any file names that still have it. It's basically a Perl code regex (regular expression) substitution. Technically, the only real limit would be the maximum command line length (a little over 8,000 characters for Windows, much higher for Mac/Linux) but the command would be very, very messy and hard to troubleshoot at the point.
QuoteAlso what is the purpose of -ext jpg ?
See the
-ext (extension) option (https://exiftool.org/exiftool_pod.html#ext-EXT---ext-EXT--extension). It's used to limit processing to just jpg images. See the common mistake 2 I linked above.
QuoteI need to understand what all of the various symbols (like s/ /i etc) in the commands do. I assume that there is a list somewhere?
Not on this site, as that is pure Perl code. Any Perl tutorial site would help there. Perl code ends with a semicolon, so each semicolon in the above command indicates the separation of what would be individual lines in a normal perl program. Some more specific sites for this example would be Introduction to Regexes in Perl (https://perlmaven.com/introduction-to-regexes-in-perl) and Regular-expressions.info (https://www.regular-expressions.info/), which is a general regex tutorial.