【问题标题】:Automator Workflow Finder TagsAutomator 工作流程查找器标签
【发布时间】:2017-02-02 19:01:28
【问题描述】:

我在 Lightroom 中有数千张照片,我将它们转换为 JPEG 以节省空间。问题是这些 RAW 文件已经分类到不同的查找器标签标签中,所以当我导出为 JPEG 时,这些标签将被删除。有没有办法保留这些标签,或者只是创建一个自动化工作流程来扫描目录并找到具有 .CR2/.NEF 扩展名的确切文件名的 JPEG 并将标签应用于新的 JPEG 文件?

macOS 山脉

Mac Pro(2013 年末)

3.7 GHz 四核 Intel Xeon E5

版本 10.12.3 (16D32)

【问题讨论】:

    标签: python terminal applescript


    【解决方案1】:

    堆栈溢出不是您要求某人为您开发某些东西的地方。您应该启动您的程序,然后您可以从这里获得帮助。所以这里有一些帮助:

    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
    

    【讨论】:

    • 谢谢!你能帮我把所有的东西放在一起吗?我不确定这两段代码在哪里结合
    • 第一个答案中添加了脚本。
    • 太棒了!完美运行。现在我还需要它来包含所有子文件夹。可能吗?
    • 可以。便于 jpeg 文件夹添加“全部内容”。但不太容易在子文件夹中搜索 Row 文件,除非您确定 Raw 和 JPg 的子文件夹结构完全相同
    • 是的,它们完全一样。 JPEG和RAW文件在同一个目录
    猜你喜欢
    • 1970-01-01
    • 2013-10-06
    • 2010-11-04
    • 2015-08-13
    • 2011-12-27
    • 1970-01-01
    • 2015-12-02
    • 2013-09-28
    • 2020-12-26
    相关资源
    最近更新 更多