堆栈溢出不是您要求某人为您开发某些东西的地方。您应该启动您的程序,然后您可以从这里获得帮助。所以这里有一些帮助:
1) 没有标准的 Automator 操作来获取或设置标签。但是 Applescript 包含关于标签的功能。
2) 但是,请注意 Applescript 功能目前仅限于每个文件使用一个颜色标签,即使您可以在 Finder 中设置多个颜色标签。因此,如果您为每个 CR2 或 NEF 文件设置了多个颜色标签,Applescript 将无法帮助您
3) 您需要在您的 JPEG 文件中构建一个“重复”循环,并为每个文件提取不带扩展名的名称。这可以通过以下方式完成:
tell application "Finder"
set N to name of aFile
set Ext to name extension of aFile
set BaseName to text 1 thru ((length of N) - (length of Ext) - 1) of N
end tell
4) 您必须使用该名称添加 2 个可能的扩展名(CR2、NEF)并搜索该文件是否存在于原始文件夹中。您可以通过使用 Finder 功能“存在”来做到这一点
5) 如果存在 CR2/NEF 文件,则获取标签并使用文件属性“标签索引”将其设置为您的 jpeg 文件:
set myLabel to label index of file CR2 -- to read CR2 file label
set label index of aFile to myLabel -- to assign the label found to your new jpg file
6) 因为您的 Jpg 文件与原始文件位于相同的文件夹/子文件夹中,您只需选择一个包含所有文件的文件夹。对于每个 jpg,您在同一文件夹级别搜索原始文件是否存在。包含文件的文件夹由“容器”调用。要从所有子文件夹级别获取文件,请使用“整个内容”。我只是添加了一个过滤器,只获取扩展名为“JPG”或“jpg”的文件。您可能需要将该列表扩展到您的扩展程序。
它提供了所有这些:
-- possible values label index: 0= no label, 1=orange, 2=Red, 3=yellow, 4=blue, 5=pink, 6=green, 7=grey
set myFolder to choose folder with prompt "Select folder containing JPEG and raw files"
tell application "Finder"
set JPEGFiles to every file in entire contents of folder myFolder whose name extension is in {"JPG", "jpg"}
repeat with aFile in JPEGFiles -- loop through all jpeg files
-- extract name of Jpg file without extension
set N to name of aFile
set Ext to name extension of aFile
set parentFolder to (container of aFile) as string -- get folder
set BaseName to text 1 thru ((length of N) - (length of Ext) - 1) of N
-- build possible raw file names with extension .CR2 or .NEF
set CR2 to (parentFolder & BaseName & ".CR2") as string
set NEF to (parentFolder & BaseName & ".NEF") as string
-- search existing label and assign it to jpg file
set myLabel to 0 -- default no label
if CR2 exists then set myLabel to label index of file CR2 -- get label of .CR2 if exists
if NEF exists then set myLabel to label index of file NEF -- get label of .NEF if exists
if myLabel > 0 then set label index of aFile to myLabel -- if label found, assignment to jpg file
end repeat -- loop to next file in jpg folder
end tell