9 Replies Latest reply on May 12, 2017 10:28 AM by johnrellis

    Match lost files by meta data

    Benny800

      Hey guys,

       

      I lost some files on my harddrive (again). I was able to recover them from my sd card, but the problem is that they were renamed during recovery so LR doesn't recognize thme anymore. Is there a way to match lost files by meta data - which is still good?

       

      Cheers

      Dennis

        • 1. Re: Match lost files by meta data
          Akash Sharma Adobe Employee

          Hi Dennis,

           

          Please take a look at this article Lightroom – Renaming Using Metadata « Julieanne Kost's Blog  and let us know if that helps.

           

          Thanks,

          Akash

          • 2. Re: Match lost files by meta data
            johnrellis Most Valuable Participant

            Unfortunately, when files have been renamed, the only way to match missing files is manually, one at a time.

             

            If this is not feasible, then if you're proficient with scripting, you could use the List View plugin to export to a text file the list of all photos in the catalog, including their filenames and relevant metadata.  Then you could use the free ExifTool to generate a similar list for all the photos on your hard drive.  You could then generate a script that matches up the photos based on metadata and renames them to the names they have in the catalog.   But I'm pretty good at such scripting, and it would probably take me at least two hours to do this.

             

            Some cameras store the sequence number of the photo in a proprietary metadata field. For example, a photo originally named IMG_3221.NEF would have "3221"  stored in that field. If your camera is one of them, a simpler method might be to use Exiftool to the sequence numbers and generate a script that renames the recovered photos based on that sequence numbers.  It appears that at least some Nikons store the sequence number, but my Canon and Sony don't.  This would probably take me about an hour to get right.

            • 3. Re: Match lost files by meta data
              Benny800 Level 1

              the only way to match missing files is manually, one at a time.

              Hm, that would take me hours. There are some thousand files.
              I already tried renaming the lost files to update the source path, but it's not possible once they are lost.

               

              Some cameras store the sequence number of the photo in a proprietary metadata field.

              Unfortunately I'm using a canon.

               

              If this is not feasible, then if you're proficient with scripting, you could use the List View plugin

              Since I'm not fond of matching thousand of files a probably spent the same time in scripting. At least thats more fun. I will try my look this way when I have some time left. Thanks for your help.

              • 4. Re: Match lost files by meta data
                johnrellis Most Valuable Participant

                I looked at all my Canon original photos more closely, and with almost all of them, the field MakerNotes:FileNumber does contain the sequence number appearing in the filename.  E.g. IMG_9721.CR has the field MakerNotes:FileNumber = 9721.   Some eight-year-old Powershot G9 .jpgs have some other value in the FileNumber field, but looking more closely, I think that's because the MakerNotes got corrupted somewhere along the way (not uncommon for apps to do that).

                 

                So that suggests an easier method:

                 

                1. Use ExifTool to extract the FileNumber field from the recovered photos, and use the output to generate a script that renames the files back to their original filenames.  Beware that there could be multiple files with the same 4-digit sequence number, so you'd have to put the duplicates into separate folders.   But use as few folders as possible (see step 2).

                 

                2. In the LR catalog, select one of the missing photos and click on the exclamation mark in the upper-right corner of the thumbnail, then click Locate. In the lower-left of the file-open window, click Options and make sure that Find nearby Missing Photos is selected.  Then navigate to the new location of the photo and select it.  All of the other photos in that folder should be automatically matched up.

                • 5. Re: Match lost files by meta data
                  Benny800 Level 1

                  I looked at all my Canon original photos more closely, and with almost all of them, the field MakerNotes:FileNumber does contain the sequence number appearing in the filename

                  Thank for looking again. I just checked that and it seems that the field ist now called "File Index". I almost overlooked it because I was searching for "sequence" somewhat.

                  I need to check if the exif data of my recovered photos is still okay since I only tested with my local files, but that seems like a good way. Thank again for your effort. I will report this evening when I'm back home with my photos

                  • 6. Re: Match lost files by meta data
                    Benny800 Level 1

                    I went the scripting way and wrote a little script using exiftool and data from LR Transporter to match files by aperture, iso, shutterspeed and date. I think in most modes the first three will be the same so date is the main matching factor. Unfortunately the file size isn't stored anywhere. This would be another good matching factor.

                     

                    I published the PHP scripts I used - one for renaming with file index and one with the other meta data - on github. https://github.com/pixelarbeit/lightroom-filematcher

                    Maybe it will help someone.

                     

                    Cheers and thanks for your help.

                    • 7. Re: Match lost files by meta data
                      johnrellis Most Valuable Participant

                      Unfortunately the file size isn't stored anywhere.

                      Both LR/Transporter and List View can export the file size, but they appear to export the formatted version, e.g. "6.01 MB".  So the matching script would have to do fuzzy matching on the file size.   My Any Filter plugin can export the file size in bytes, along with 352 other fields.

                       

                      Glad you were able to resolve the problem

                      • 8. Re: Match lost files by meta data
                        Benny800 Level 1

                        Both LR/Transporter and List View can export the file size, but they appear to export the formatted version

                        Yes, they can export the file size, BUT it's seems to be not stored in the catalogue but calculated with the original file. When I tried to export it I only got a "Can't find file" error.

                        • 9. Re: Match lost files by meta data
                          johnrellis Most Valuable Participant

                          Yes, they can export the file size, BUT it's seems to be not stored in the catalogue but calculated with the original file.

                          You're right -- I never knew that.   The plugin SDK reports "nil" for the file size of missing files.  I poked around in the catalog database internals, and LR does store file size for files synced with LR Mobile, but not in general for all photos.