1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Welcome to Lightroom Forums! We're a friendly bunch, so please feel free to register and join in the conversation. If you're not familiar with forums, you'll find step by step instructions on how to register and post your first thread under Help on the menubar above. You're also welcome to join our newsletter, download our free Lightroom Quick Start eBook and explore our other FAQ resources.
    Dismiss Notice

managing "export" setting of many keywords

Discussion in 'Lightroom 1-6 for Windows & Mac (perpetual)' started by dap, Jul 3, 2011.

  1. dap

    dap New Member

    Joined:
    Jul 3, 2011
    Messages:
    4
    Lightroom Experience:
    Intermediate
    Primary OS:
    Mac 10.6.x Snow Leopard
    Is there any way to bulk-edit the "export" property of many keywords?

    I haven't been careful about correctly setting the "export" property for keywords, so nearly all of them are set to be exported. But I always check "minimize embedded metadata" on export so they don't show up in the exported image. Now I want to start including metadata and most of the keywords, but I've got large groups of keywords (which are pretty much arranged hierarchically) that I don't want exported. Setting the parent to not be exported doesn't seem to prevent the others from being exported -- it looks like I have to set it on each one individually. Is there any way to bulk-edit the keywords so that they aren't exported?

    I also tried exporting, editing the text file, and importing again, but this had no effect.

    I've heard you can edit the SQLite database directly, but I don't really want to much with that unless there's a supported way to do it.

    Thanks in advance!
     
  2. clee01l

    clee01l Lightroom Guru Staff Member Lightroom Guru

    Joined:
    Jun 20, 2009
    Messages:
    13,270
    Location:
    Bellaire, TX USA
    Lightroom Experience:
    Power User
    Primary OS:
    Mac 10.13.x High Sierra
    Lightroom Version:
    Classic 7
    Lightroom License:
    CC Subscription
    Welcome to the forum. These are the only two ways that I can think of to manipulate the attributes of the keywords other than one by one. I'm not sure if method 1 (export/import) will work but it ought to be possible. Method number 2 (Update the SQLite table(s) ) will work and there are various SQL managers that you can use to edit the catalog directly. It is always safe to work with a copy of the catalog. That way if your SQL updates break referential integrity, you have the original catalog copy to fall back on.
    If you are interested in following up on method 2 with a copy of your current catalog, I can probably produce the SQL statement to update the proper table(s).
     
  3. dap

    dap New Member

    Joined:
    Jul 3, 2011
    Messages:
    4
    Lightroom Experience:
    Intermediate
    Primary OS:
    Mac 10.6.x Snow Leopard

    Thanks for the advice. Method (1) doesn't work to change the "export" setting. I'm wary of method (2), but if that's the only way, I might just have to go for it.

    -- Dave
     
  4. johnbeardy

    johnbeardy Senior Member Staff Member Moderator Lightroom Guru

    Joined:
    Oct 8, 2007
    Messages:
    4,391
    Location:
    London
    Lightroom Experience:
    Power User
    Primary OS:
    Windows 10
    Lightroom Version:
    6.6 / CC 2015.6
    Lightroom License:
    CC Subscription
    You're right to be wary - see here. You can do it through the SDK mechanism and it is the supported way.

    John
     
    Last edited: Jul 3, 2011
  5. dap

    dap New Member

    Joined:
    Jul 3, 2011
    Messages:
    4
    Lightroom Experience:
    Intermediate
    Primary OS:
    Mac 10.6.x Snow Leopard
    John,

    Thanks for the tip. I looked into the SDK and wrote a plugin to do precisely this. I'm attaching it here for future reference, though it should be noted that I've never seen Lua nor the LR SDK before this morning, so it should be used with caution.

    To use this script I wrapped it inside a plugin that just adds a Library menu item to invoke this script:

    Code:
    --
    -- This script is provided for reference only.  Do *not* run this without
    -- understanding how it works.  It was written by an amateur.
    -- 
    -- This script is intended to hide keywords whose top-level parent keyword is
    -- not hidden (marked for export), and warn about keywords which are hidden
    -- whose top-level parent is not hidden.  That is, this script iterates the
    -- keywords in the active catalog.  For each one, if its top-level parent
    -- keyword is marked for export but this keyword is not, the script prints a
    -- warning.  If its top-level parent keyword is not marked for export but the
    -- keyword itself is, this script unmarks the keyword for export.
    --
    
    
    local LrDialogs = import 'LrDialogs'
    local LrLogger = import 'LrLogger'
    
    
    local log = LrLogger( 'dapLogger' )
    log:enable( "logfile" )
    log:trace("BEGIN")
    
    
    -- Track how many keywords we've hidden.
    local nhidden = 0;
    
    
    --
    -- Hide the given keyword and its children (recursively).
    --
    local function fixKeyword(keyword)
        local attrs = keyword:getAttributes()
    
    
        if not attrs.includeOnExport then
            log:trace("skipping '" .. keyword:getName() .. "' (already not exported)")
        else
            log:trace("hide keyword '" .. keyword:getName() .. "'")
            keyword:setAttributes({ includeOnExport = false });
            nhidden = nhidden + 1
        end
    
    
        for key,child in pairs(keyword:getChildren()) do
            fixKeyword(child)
        end
    end
    
    
    --
    -- Check that the given keyword and its children are not hidden (recursively).
    --
    local function checkKeyword(keyword)
        local attrs = keyword:getAttributes()
    
    
        if not attrs.includeOnExport then
            log:trace("surprised to find '" .. keyword:getName() .. "' not exported");
        end
    
    
        for key,child in pairs(keyword:getChildren()) do
            checkKeyword(child)
        end
    end
    
    
    --
    -- Body of this operation: start an asynchronous task that modifies the catalog
    -- as described above.
    --
    import "LrTasks".startAsyncTask(function ()
        local catalog = import "LrApplication".activeCatalog()
        local allkeywords = catalog:getKeywords()
    
    
        catalog:withWriteAccessDo('Hide specific keywords', function ()
            for key,keyword in pairs(allkeywords) do
                local attrs = keyword:getAttributes()
                if not attrs.includeOnExport then
                    fixKeyword(keyword)
                else
                    checkKeyword(keyword)
                end
            end
        end)
    
    
        LrDialogs.message('Hid ' .. nhidden .. ' keywords.', '', 'info')
        log:trace("END")
    end)
    
     
  6. johnbeardy

    johnbeardy Senior Member Staff Member Moderator Lightroom Guru

    Joined:
    Oct 8, 2007
    Messages:
    4,391
    Location:
    London
    Lightroom Experience:
    Power User
    Primary OS:
    Windows 10
    Lightroom Version:
    6.6 / CC 2015.6
    Lightroom License:
    CC Subscription
    You did that quickly! It took me ages to get my head around Lua!John
     
  7. clee01l

    clee01l Lightroom Guru Staff Member Lightroom Guru

    Joined:
    Jun 20, 2009
    Messages:
    13,270
    Location:
    Bellaire, TX USA
    Lightroom Experience:
    Power User
    Primary OS:
    Mac 10.13.x High Sierra
    Lightroom Version:
    Classic 7
    Lightroom License:
    CC Subscription
    And some of us still don't have a handle on the SDK. I'm envious!
     
  8. dap

    dap New Member

    Joined:
    Jul 3, 2011
    Messages:
    4
    Lightroom Experience:
    Intermediate
    Primary OS:
    Mac 10.6.x Snow Leopard

    I still wouldn't say I know much Lua :) But having written a lot of code in other languages, I was able to cobble together enough to solve this narrow problem.

    Thanks again for the tip! Makes me think there's an opportunity for someone to write a better keyword management interface for Lightroom.

    -- Dave
     
  9. Kiwigeoff

    Kiwigeoff Lightroom Guru Lightroom Guru

    Joined:
    Oct 7, 2007
    Messages:
    4,627
    Location:
    Paradise
    Lightroom Experience:
    Power User
    Primary OS:
    Mac 10.10.x Yosemite
    Lightroom Version:
    5.7
    I agree a whole window for keyword management would be brilliant, something like the Import window. A post on the bug report forum linked at the top of this page would garner many votes I believe.
     

Share This Page