This Script Made Cry- Lightroom Mass Delete previous step

While color correcting a client’s wedding today in Lightroom, I accidentally chose to ‘read metadata’ instead of ‘save metadata’.  Typically a nice little undo would save the day.  However I have known issue that I refuse to take time to fix where sometime my ctrl+z does some crazy thing like run a preset, not always though.  Of course it happened this time and the more I tried to undo the worse the problem got.  Thankfully I found this great SQL script to take all my images in a collection and revert back one step (http://forums.adobe.com/message/3171709) The following SQL query was provided by Dorin Nicolaescu-Musteață over on the Adobe Forums. I take no credit for this. By following the instructions beneath the code, you will be able to take all images in your selection and step back in history one step.  
UPDATE adobe_imagedevelopsettings   
   SET text = 
          (SELECT hs1.text
              FROM adobe_libraryimagedevelophistorystep hs1
             WHERE hs1.image = adobe_imagedevelopsettings.image
               AND hs1.id_local =
                      (SELECT MAX (hs2.id_local)
                         FROM adobe_libraryimagedevelophistorystep hs2
                        WHERE hs2.image = adobe_imagedevelopsettings.image
                          AND hs2.id_global <>
                                   adobe_imagedevelopsettings.historysettingsid)),

        historysettingsid =
           (SELECT hs1.id_global
              FROM adobe_libraryimagedevelophistorystep hs1
             WHERE hs1.image = adobe_imagedevelopsettings.image
               AND hs1.id_local =
                      (SELECT MAX (hs2.id_local)
                         FROM adobe_libraryimagedevelophistorystep hs2
                        WHERE hs2.image = adobe_imagedevelopsettings.image
                          AND hs2.id_global <>
                                   adobe_imagedevelopsettings.historysettingsid)),

        digest = NULL WHERE image IN (SELECT ci.image
                    FROM aglibrarycollectionimage ci, aglibrarycollection c
                   WHERE c.id_local = ci.collection AND NAME LIKE 'ScrewAutoSync')
      AND (SELECT COUNT (*)
           FROM adobe_libraryimagedevelophistorystep
          WHERE image = adobe_imagedevelopsettings.image) > 1

  So, here’s what one has to do:
  1. Backup catalog.
  2. Create a collection called “ScrewAutoSync” and add all affected images into it.
  3. Close Lightroom, open your catalog in an SQLite utility and run the above query.

Tags: