Parsing tag data

Started by StarGeek, August 08, 2013, 04:47:43 PM

Previous topic - Next topic

StarGeek

I'm trying to figure out the best way to print out part of a tag, in this case the Caption-Abstract.  In the tag, there's some data I want to print out that's between an end bracket+whitespace and a whitespace+start bracket ([bbcode] Data I want [/bbcode]).  I'm currently using this command
exiftool -p "${caption-abstract;s/.*?\]\s(.*?)\s\[.*/$1/s}" <file>
and that sorta feels messy and I'm wondering if I'm missing an easier solution due to my lack of Perl knowledge.

Any thoughts/suggestions?
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

Sometimes regular expressions can be messy.  The only alternative I can suggest right now isn't much better:

"${caption-abstract;/\]\s*(.*?)\s*\[/;$_=$1}"

- 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

Sounds good, thanks.

I was just thinking I might have been missing a simpler solution.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype