metadata to photo file name

Advanced Renamer forum
#1 : 14/03-22 18:50
MartinR
Posts: 2
Hello everyone. I need an extract of metadata added to the filename

Filename: IMG_20201010_0004.jpg
Metatags: lorem, Access_A, Access_B, Ipsum, Access_C
target filename: IMG_20201010_0004_[ABC].jpg

Adding tags to filename is already working with the add method "_[<ExifTool:LastKeywordXMP>]"
Now i am struggeling to remove all unnecessary tags "lorem, " & "Ipsum"
Is there a parsing of the taglist possible before adding to filename (regex or script)?
Unfortunatly i am not a programmer.

The purpose of this:
With help of tagging photos, i want specifiy which person can see the photo. (Person A, and/or B... C)
The photos will than be send/synced to the photo library of the person by filtering on filename.

please guide .. thanks ..

edited: 14/03-22 19:59
#2 : 15/03-22 15:50
David Lee
Posts: 1125
Metadata tags tend to be manufacturer specific. You shouldn't assume that anyone will know what you are talking about so you should explain exactly what the tag is returning!

However, whilst I know nothing about LastKeywordXMP it would appear to be a Microsoft specific tag and from the context of your post I am assuming that it probably returns a comma-separated string of characters.

You cannot parse metadata tags directly from Advanced Renamer batch Methods so the simplest solution would be to add the entire tag to the filename - possibly with a suitable separator - and then add a replace method to remove the unwanted text using a regular expression.

Alternatively you can read the contents of the tag into a variable in a Script method:

XMPtag = app.parseTags("<ExifTool:LastKeywordXMP>");

If you need any more assistance then please post the contents that will be returned by the metadata tag and be more specific about exactly how you want to parse it into the filename.
#3 : 15/03-22 20:52
MartinR
Posts: 2
Thank you pointing me to the right direction. solved.

prerequisite:
Tagged file: IMG_2020.jpg
applied tags: aaa, Access_A, ee, Access_B, tt
(aaa, ee, tt) are placeholder other unknown tags.

1. Add tags to file:
add: _[<ExifTool:LastKeywordXMP>]
result: IMG_2020_[aaa, Access_A, ee, Access_B, tt].jpg

2. replace characters from "_[" to "Access_" by nothing
searchtext: _\[\K(.*?)(?=Access)
result: IMG_2020_[Access_A, ee, Access_B, tt].jpg

3. replace characters from "Access_?" to "Access_?" by nothing
searchtext: Access_.\K.*?(?=Access_.)
result: IMG_2020_[Access_AAccess_B, tt].jpg

4. replace characters from "Access_?" to "]" by nothing
searchtext: ((Access_.)(?!.*Access_.))\K.*(?=\])
result: IMG_2020_[Access_AAccess_B].jpg

5. replace characters "Access_" by nothing
searchtext: ((Access_.)(?!.*Access_.))\K.*(?=\])
end result: IMG_2020_[AB].jpg

edited: 15/03-22 21:08
#4 : 16/03-22 10:36
David Lee
Posts: 1125
Reply to #3:
You can simplify this to a single replace method by using a regular expression.

Replace: (.*)\[.*?Access_(\w)(.*?Access_(\w))?(.*?Access_(\w))?.*
with: \1[\2\4\6]
Use regular expressions

Since you originally specified three Access tags (A,B,C) this will work with one, two or three such tags.

edited: 16/03-22 15:26