I've found [here on StackOverflow][1] how to:
- choose a folder
- filter only the XMP-files
- store the name of the XMP-files in an array
Here's the modified part of the AppleScript:
---
-- we can check the file extensions of a file against this list to
evaluate if it's a XMP file
set xmp_ext_list to {"xmp"}
-- get the folder to check
set f to choose folder
-- notice the use of "entire contents" to also go through subfolders of
f
-- use a "whose" filter to find only the video files
tell application "Finder"
set xmpFiles to (files of entire contents of f whose name extension is
in xmp_ext_list) as alias list
end tell
---
I'm still searching for the missing pieces… :-)
[1]:
https://stackoverflow.com/questions/7854727/loop-over-video-files-in-folder-to-get-video-length
On 14 Mar 2020, at 16:55, Vlad Ghitulescu wrote:
Jean-Christophe,
thanks a lot for your reply!
Google-ing (see my first email) I've found already [the very same
AppleScript from Shane Stanley back in 2002 (!)][1] - so yes, that's
another puzzle piece! Hurray! :-)
I'm still missing a lot:
1. I don't know how to peek the first XMP-file in the chosen folder
and then apply the magic of extracting the IPTC-keywords of it. This
is what I've manually done with BBEdit, but I don’t know how to put
it in an AppleScript / RegEx :-(
2. How do I pipe the result from point 1 to Shane Stanley's
AppleScript? (*)
3. And how do I tell to the above AppleScript to which CR2 / JPG /
TIFF - file (with the same name as the XMP-file from point 1 above) to
apply the tags (= IPTC-keywords) extracted from the XMP-file in point
1 above?!
4. And finally: How do I loop to the next XMP-file within the chosen
folder?
It feels like I have less than I'm missing right now! :-D
At least the points 1, 2 and 4 *seem* trivial… I'll google them.
Thanks again, Jean-Christophe!
Regards,
Vlad
(*): I've found [a hint from Dr. Drang in an AppleScript called from
KeyboardMaestro to tag a file][2]. What I like about it is that it
uses a list of tags… that could be the result of my point 1 above!
:-) Ok, I still don't know how to pipe it to Keyboard Maestro, so I'm
still on square (= point ;-) 1! :-(
[1]: https://www.macscripter.net/viewtopic.php?id=45167
[2]:
https://leancrew.com/all-this/2018/10/a-little-tagging-automation/
On 14 Mar 2020, at 16:19, Jean-Christophe Helary wrote:
Vlad,
You're just a few AppleScript lines away from solving your project.
The problem is that Finder's dictionary does *not* provide access to
"modern" tags. So we have to code that with AS but we don't have to
reinvent the wheel since Shane Stanley has already written *the* code
that you can use to manipulate tags in AS.
I am not sure the link points at the canonical version, but that's
the one I use for reference:
https://lists.apple.com/archives/applescript-users/2015/Jan/msg00193.html
Jean-Christophe
On Mar 14, 2020, at 23:44, Vlad Ghitulescu <[email protected]>
wrote:
Hey!
What I've got so far:
• I manage to extract the IPTC-keywords from the initial example:
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.6.0">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
xmlns:xmp="http://ns.adobe.com/xap/1.0/"
xmlns:photomechanic="http://ns.camerabits.com/photomechanic/1.0/"
photoshop:DateCreated="2018-05-10T13:35:00.03"
xmp:CreateDate="2018-05-10T13:35:00.03"
xmp:Rating="0"
photomechanic:ColorClass="0"
photomechanic:Tagged="False"
photomechanic:Prefs="0:0:0:-00001"
photomechanic:PMVersion="PM6">
<dc:subject>
<rdf:Bag>
<rdf:li>Ben</rdf:li>
<rdf:li>Mina</rdf:li>
<rdf:li>Tom</rdf:li>
<rdf:li>Vlad</rdf:li>
</rdf:Bag>
</dc:subject>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
using BBEdit's "Process Line Containing…"-command, where I
searched for
<rdf:li>
• I replaced (manually, not via a script etc.) then
• first
<rdf:li>
• and then
</rdf:li>
with nothing.
The result:
Ben
Mina
Tom
Vlad
are the 4 IPTC-Keywords that I want to set as Finder-tags to the CR2
/ JPG / TIFF - file with the same name as the XMP-file.
• I've found an Automator-action that can assign tags to files or
folders.
<Bildschirmfoto 2020-03-14 um 15.39.50.png>
These are only a couple of pieces of the whole puzzle and right now
I don't have a clue how to "glue" them together :-(
Any help would be greatly appreciated.
Regards,
Vlad
On 13 Mar 2020, at 13:44, Vlad Ghitulescu wrote:
I was inexact regarding file-names and -number:
• the XMP-file and the photo-file have the same name AND
• there is most of the time more than one photo-file, because I
shoot in RAW (that’s CR2 for me, shooting Canon) and all of the
edited versions are JPG, once in a while TIFF.
So for a given photo „PhotoName“ I have always at least two
files
PhotoName.CR2 (the RAW-file)
PhotoName.XMP (the metadata-file, I was hard-working enough to take
care of the metadata ;-)
and for the most of the photos there are even some other edited
versions as
PhotoName.JPG
PhotoName-1.JPG
PhotoName-bw.JPG
PhotoName.TIFF
The edited versions all begin with A but can have a) some data added
to the end of the file-name (as digits for various versions or -bw
for black & white) and b) some other file-extensions (JPG and once
in while TIFF).
That make my dream-script a little more complicated:
• take this photo-folder;
• read from the first XMP-file the IPTC-keywords;
• copy all of this IPTC-keywords as Finder-tags to all of the
files with the suffixes CR2, JPG or TIFF of which the file-name
begins with the same name as the XMP-file;
• loop within the photo-folder until there is no XMP-file
anymore.
I hope that now is more clearer.
Thanks in advance!
Regards,
Vlad
On 13 Mar 2020, at 8:18, Vlad Ghitulescu wrote:
Hey!
This is a BBEdit-question, but I first need to give a little
background to it. :-)
As all photographers here already know, the metadata to the photos
lives in a suplimentary XMP-file.
Here is a sample of a XMP-file for one of my photos, where I filled
in the so called IPTC-keywords in Photo Mechanic:
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.6.0">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
xmlns:xmp="http://ns.adobe.com/xap/1.0/"
xmlns:photomechanic="http://ns.camerabits.com/photomechanic/1.0/"
photoshop:DateCreated="2018-05-10T13:35:00.03"
xmp:CreateDate="2018-05-10T13:35:00.03"
xmp:Rating="0"
photomechanic:ColorClass="0"
photomechanic:Tagged="False"
photomechanic:Prefs="0:0:0:-00001"
photomechanic:PMVersion="PM6">
<dc:subject>
<rdf:Bag>
<rdf:li>Ben</rdf:li>
<rdf:li>Mina</rdf:li>
<rdf:li>Tom</rdf:li>
<rdf:li>Vlad</rdf:li>
</rdf:Bag>
</dc:subject>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
The individual data is the creation-date:
photoshop:DateCreated="2018-05-10T13:35:00.03"
xmp:CreateDate="2018-05-10T13:35:00.03"
and the IPTC-keywords:
<rdf:li>Ben</rdf:li>
<rdf:li>Mina</rdf:li>
<rdf:li>Tom</rdf:li>
<rdf:li>Vlad</rdf:li>
Another background-information that probably all of you know: there
is no relation between the IPTC / XMP - keywords and the Finder /
macOS - tags.
And this exactly is my problem.
I need to input somehow / somewhere the metadata to my photos, but I
don't want to make this twice in order to have this information
present in the IPTC-keywords AND in the Finder-tags as well.
This is not new at all: Google-ing about "copy IPTC-keywords into
Finder-tags" or viceversa I've found a lot but all of it involved in
one step or another the EXIFtool, a command line utility that reads
and writes photo-metadata… and this doesn't scale very well (I
have A LOT of photos: about 220,000 pics that are more than 2 TB
big!) and it is slow, because the EXIFtool have to read the metadata
from the photo.
So my idea is to take care or the IPTC-keywords in Photo Mechanic
(this would create a XMP-file as the one above for every photo I
have) and then - and here comes BBEdit! :-) - somehow transfer the
data from the XMP-file (that is in the end only a text-file!) to the
Finder-tags.
Now finally to my question (sorry for the length!): How could I
• take each IPTC-keyword (delimited by the tag < rdf:li >, see
above) and
• write this IPTC-keyword into a Finder-tag
for every photo in a folder?
Ideally I'd have a script, point it to a folder full of photos and
BOOM!, after this every photo would have the same Finder-tags as the
IPTC-keywords!
Could you please help me with this?
Thanks in advance!
Regards,
Vlad
--
This is the BBEdit Talk public discussion group. If you have a
feature request or need technical support, please email
"[email protected]" rather than posting here. Follow @bbedit on
Twitter: https://twitter.com/bbedit
--- You received this message because you are subscribed to the
Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/93FE2214-4BDD-4C41-952F-61C910E44C38%40Ghitulescu.de.
--
This is the BBEdit Talk public discussion group. If you have a
feature request or need technical support, please email
"[email protected]" rather than posting here. Follow @bbedit on
Twitter: https://twitter.com/bbedit
--- You received this message because you are subscribed to the
Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/E3AD63CE-D6D0-4FD0-A317-514C772BFBC9%40Ghitulescu.de.
--
This is the BBEdit Talk public discussion group. If you have a
feature request or need technical support, please email
"[email protected]" rather than posting here. Follow @bbedit on
Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google
Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/74E567C0-F5BE-48D8-A30F-9EEBEA2737C7%40Ghitulescu.de.
Jean-Christophe Helary
-----------------------------------------------
http://mac4translators.blogspot.com @brandelune
--
This is the BBEdit Talk public discussion group. If you have a
feature request or need technical support, please email
"[email protected]" rather than posting here. Follow @bbedit on
Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google
Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/85ED17EA-5E51-4CA7-AD1E-B1C557942702%40traduction-libre.org.
--
This is the BBEdit Talk public discussion group. If you have a feature
request or need technical support, please email
"[email protected]" rather than posting here. Follow @bbedit on
Twitter: <https://twitter.com/bbedit>
--- You received this message because you are subscribed to the Google
Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/AB4D6C1B-1E4B-48D1-B451-F14B9850FA12%40Ghitulescu.de.
--
This is the BBEdit Talk public discussion group. If you have a feature request or need
technical support, please email "[email protected]" rather than posting here.
Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/917DCE2C-6D28-4679-A1AE-5D8E54C453F8%40Ghitulescu.de.