Hello,
i'm new here and need help with exiftool.
I got thousands of photos in a folder and i would like to remove everything after some fix values (fix values included) in all that images in the iptc caption field 120.
Example before:
HOLLYWOOD - APRIL 30: Actors James Morrison (L) and Jeffrey Nordling attend Fox's "24" Series Finale Party held at Boulevard 3 on April 30, 2010 in Hollywood, California. (Photo by XXX/YYY) /-DDD-
HOLLYWOOD - APRIL 30: Actors James Morrison (L) and Jeffrey Nordling attend Fox's "24" Series Finale Party held at Boulevard 3 on April 30, 2010 in Hollywood, California. Photo:
HOLLYWOOD - APRIL 30: Actors James Morrison (L) and Jeffrey Nordling attend Fox's "24" Series Finale Party held at Boulevard 3 on April 30, 2010 in Hollywood, California.
Credit: XXX/YYY
HOLLYWOOD - APRIL 30: Actors James Morrison (L) and Jeffrey Nordling attend Fox's "24" Series Finale Party held at Boulevard 3 on April 30, 2010 in Hollywood, California.
Photo: XXX/CCC
Example after:
HOLLYWOOD - APRIL 30: Actors James Morrison (L) and Jeffrey Nordling attend Fox's "24" Series Finale Party held at Boulevard 3 on April 30, 2010 in Hollywood, California.
Can i use a batch script to start the action?
i Just found that, but my english is not so good to understand all of that, how to use it
exiftool "-iptc:caption-abstract
Thanks a lot
André
On example #2, does it just end with "Photo:" or is there supposed to be something after it?
The basic command would be something like this:
exiftool "-Caption-Abstract<${Caption-Abstract;s/\(Photo by.*?$//;s/Photo:$//;s/^Credit:.*//m;s/^Photo:.*$//m;}" FileOrDir
But you would have to be very careful with this. If any of these patterns just happened to occur earlier in the string then it would be truncated at that point.
This command would only work on the IPTC:Caption-Abstract tag in the files. You might also check to see if XMP:Description also contained data.
This command creates backup files. Add -overwrite_original to suppress the creation of backup files. Add -r to recurse into subdirectories. If this command is run under Unix/Mac, reverse any double/single quotes to avoid bash interpretation.
Hi StarGeek,
thanks for your answere. I will try it
After each example there are more then just "Photo or Credit"
Quote from: Tribo0n on November 23, 2018, 03:08:26 AM
After each example there are more then just "Photo or Credit"
In that case, in the above command, change
s/Photo:$//; to
s/Photo:.*?$//;
Thanks a lot, it works now
@echo off
exiftool "-Caption-Abstract<${Caption-Abstract;s/\(Photo by.*?$//;s/Photo:.*?$//;s/^Credit:.*//m;s/^Photo:.*$//m;}" D:\Test\ -overwrite_original
pause
The script didn't remove the the next paragraph. What need to be change that everything after Photo by will be removed?
How can i remove (testtest/ and all following content? If i edit the script it gives an error. I think its cause of ( and /
André
You're correct, you have to escape the ( and / by putting a backslash in front of them. So, s/\(testtest\/.*//;
All of these characters [/\^$.|?*+() need to be escaped as they have special meanings in regex (Regular Expressions).
You can use RegEx101 (https://regex101.com/) to test things. Each s/ / / is a single regex expression, where what matches between the first two slashes is replaced by what's between 2nd and 3rd slash. There are certain options you can place after the 3rd slash as modifiers.
Regex is a very complex subject and there are lots of websites out there that go into more depth on the subject.
Quote from: Tribo0n on November 23, 2018, 08:16:17 AM
The script didn't remove the the next paragraph. What need to be change that everything after Photo by will be removed?
Add ;s/Photo.*//
- Phil
It don't remove the next paragraph
Thats my code:
@echo off
exiftool "-Caption-Abstract<${Caption-Abstract;s/Credit:.*//;s/Credit by.*//;s/Photo:.*//;s/Photo by.*//;s/\(Photo by.*?$//;s/Photo:.*?$//;s/^Credit:.*//m;s/^Photo:.*$//m;}" "-artist=XXX" "-CopyrightNotice=XXX" "-Credit=XXX" "-Source=XXX" "-Writer-Editor=XXX" "-Contact=XXX" "-By-line=XXX" "-By-lineTitle=XXX" "-OriginalTransmissionReference=XXX" "-SpecialInstructions=" "-SupplementalCategories=" "-LocalCaption=" F:\test\ -overwrite_original -r
pause
Example
Bla Bla Bla at Hamburg, Germany
Photo by XXX/YYY
Ref: 356
Hamburg
Everything after Photo by should be removed. Whats wrong?
Try s/Photo.*//s
You might also try changing any trailing m's in the previous commands to s. I was trying to be careful with what was deleted in my original post. The trailing m treats each line separately (multi-line). The s treats the whole thing as a single line.
Is it possible to modify this command by having a text file with all values from which the caption should be cutted off?
This is my code:
@echo off
exiftool "-Caption-Abstract<${Caption-Abstract;s/Credit:.*//s;s/credit:.*//s;s/Credit by.*//s;s/credit by.*//s;s/Photo:.*//s;s/photo:.*//s;s/Photo by.*//s;;s/photo by.*//s;;s/Photo By.*//s}" F:\images -overwrite_original -r
pause
The .bat file is a text file. And it contains all of the values to be cut off.
If your question is about a different format text file, the answer is "no".
- Phil
Yeah, i mean a diffrent formated text file
For example this.
credit:
Credit:
credit by:
Photo:
photo:
Photo by:
photo by:
Photo by
I can't think of a way to do this.
- Phil