Remove first five characters of regionname content

Started by brunos, February 22, 2021, 03:27:37 PM

Previous topic - Next topic

brunos

All,

In a photo archive of animal liberation in Italy, I've got more than 100k JPG photos in various subfolders under the same root. Plenty of photos contain the XMP face tags that appear as:

     <mwg-rs:Regions rdf:parseType="Resource">
            <mwg-rs:AppliedToDimensions rdf:parseType="Resource">
               <stDim:w>3475</stDim:w>
               <stDim:h>3241</stDim:h>
               <stDim:unit>pixel</stDim:unit>
            </mwg-rs:AppliedToDimensions>
            <mwg-rs:RegionList>
               <rdf:Bag>
                  <rdf:li rdf:parseType="Resource">
                     <mwg-rs:Name>aN0M Tony Curcio</mwg-rs:Name>
                     <mwg-rs:Type>Face</mwg-rs:Type>
                     <mwg-rs:Area rdf:parseType="Resource">
                        <stArea:x>0.66</stArea:x>
                        <stArea:y>0.338013</stArea:y>
                        <stArea:w>0.232806</stArea:w>
                        <stArea:h>0.250231</stArea:h>
                        <stArea:unit>normalized</stArea:unit>
                     </mwg-rs:Area>
                  </rdf:li>
               </rdf:Bag>
            </mwg-rs:RegionList>
         </mwg-rs:Regions>


The part I need to modify conditionally is the following one:

<mwg-rs:Name>aN0M Tony Curcio</mwg-rs:Name>

It should become:

<mwg-rs:Name>Tony Curcio</mwg-rs:Name>

In other words, in each Name, the first 4 letters+ a space need to be removed (in this example, "aN0M " should be simply deleted).

The trouble is that there are many prefixes all different, although all exactly of the same length: 4chars+space.

Sigh, although it might be simple to cut out 4 letters+space, in the regexp "jungle" don't know even where to start! I should be ashamed and I am, but my blushing does not resolve any.

If an altruistic soul knows the way, please please please, share it with me.

Thanks in advance.
Bruno


StarGeek

Try
exiftool -api "filter=s/^.{5}//" -TagsFromFile @ -RegionName /path/to/files/

The -api Filter option is running a RegEx to remove the first five characters.  Then the -TagsFromFile option copies the altered RegionName back into the file.
* 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).

brunos

Thank you for your prompt reply! Will test it immediately!

Kindest regards
Bruno

brunos

Thanks again, I've tried it and it does the job!!!

Kindest regards
Bruno