I have a list of photo filenames that I uploaded to Flickr before I got Lightroom, in this format:


and I wondered: is there a way to tell Lightroom to import such a list and use it as a collection? (I've already imported all of my photos to Lightroom)

Or do I have to add the photos to a collection manually? (I've done some heavy hacking to read data from the sqlite database of Lightroom, but I don't dare modify the database myself)


Yes, you can create a Smart Collection for these images. The process is no difficult but could take a little time to complete.

Lightroom's Smart Collections exported definitions are simple text files. They are not difficult to dissect and recreate at all. Based on your description I would create a Smart Collection in Lightroom with the selection being that the filename contains "p2000518.jpg" or "p2000549.jpg" after that you could export the Smart Collection settings and open the resulting .smcol file in a text editor. It will likely look like this:

s = {
    id = "15D46923-B382-4322-A3B9-19347EBF7080",
    internalName = "File Name Selection",
    title = "File Named",
    type = "LibrarySmartCollection",
    value = {
            criteria = "filename",
            operation = "any",
            value = "p2000518.jpg",
            value2 = "",
            criteria = "filename",
            operation = "any",
            value = "p2000549.jpg",
            value2 = "",
        combine = "union",
    version = 0,

You can then continue the pattern using copy and paste or a mail merge in your word processing program. I also delete the ID number and when it reimports it worked file. I created 132 rules to do smart collections by month for the past decade and it worked no problem. Since you said you had already gone into the SQL database I figure this idea should make sense. If you need more information let me know and I can flush it out more.

  • Thanks! Worked like a charm!!! I use jsdb (jsdb.org) as my swiss-army-knife for computing, and I was able to write template lines to autogenerate the smart collection file. Then I imported it into Lightroom, and the photos appeared. Then I dragged them all into a regular collection. – Jason S Jan 2 '11 at 23:19
  • I'm still curious as to why you needed to create a smart collection by hand, instead of just matching the beginning of the filename... – sebastien.b Jan 3 '11 at 2:00
  • I made an assumption that you wanted to import the list, but yes you could write the rule to be starting with "XXXXX" or contains "XXXX" Glad it worked for you – Bradford Benn Jan 7 '11 at 17:52
  • Based on Bradford Benn's answer above, I created a tutorial in gist form, complete with Ruby script and a screencast. Hope it helps someone: gist.github.com/dergachev/6541450 – Dergachev Sep 12 '13 at 18:11
  • Great answer! Really helped! Do you know if there is possibility to match files by full path? I mean - directory with filename? Eg. Pictures\2015\March\DSC0001.jpg. It would be helpful if I have same file names across directories. There is filter for directory and file name but seems there is no way to combine them together (for more than 1 photo). – gumik Jan 7 '16 at 20:39

I'd probably import the pictures manually and then create a set from the 'Latest import'-collection. Less hacking means less risk of shrewing up :)


I'm not sure I understand. You say you want Lightroom to import a list, but you also say you already imported the photos?

Assuming you have imported all your photos in Lightroom, and what you are trying to do is create a collection of photos that all start with P2000 (followed by 3 digits and .jpg), did you try creating a simple smart collection? The first and only rule of that smart collection would be "Filename", the action "Starts with", and the parameter "P2000". Am I missing something?

Or if they have been just recently imported, you have all of them in the Catalog section in the left panel in Library Mode, under "Previous Import". Create another collection, say "Foo", right-click, select "Set as Target Collection", then go to "Previous Import", select all, right click and select "Add to Target Collection".

  • because I have 4000+ pictures so far in Lightroom and I want a particular set of 139 of them to be marked as being in a collection, where exact set of 139 matches the collection I uploaded to my flickr webpage before I started using Lightroom. – Jason S Jan 3 '11 at 3:09
  • The ones I don't want put in that collection are not distinguishable from the ones that are by any other way than filename (or by me looking at the photos). – Jason S Jan 3 '11 at 3:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.