Skip to content

Instantly share code, notes, and snippets.

@danieltroger
Last active October 8, 2020 23:30
Show Gist options
  • Save danieltroger/a831c7408cba284a04eef649550c0b3b to your computer and use it in GitHub Desktop.
Save danieltroger/a831c7408cba284a04eef649550c0b3b to your computer and use it in GitHub Desktop.
Lightroom missing files path extractor. Gives a list of all missing files from Lightroom.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<!--
How to use:
Prep work: use the Library->Find all missing photos feature of lightrom.
I also created a collection called "missing" with all missing photos, but I don't think it contributed to below working. CLOSE LIGHTROOM
Then:
Open your *.lrcat with this software: https://sqlitebrowser.org/
Select all tables in the database structure view
Go to file-> export -> table to json
select all tables again, select a destination folder, press "go"
put this script into that folder
start a web server, eg with by cd-ing to that folder in a shell and running `http-server .`
(install this before: https://www.npmjs.com/package/http-server by running npm install -g http-server)
you can also try `php -S 0.0.0.0:8080` on macOS, it should work without installing anything.
then visit localhost:8080/nameofthisfile.html in a browse
and you should get your missing files displayed
The script might run a minute or two, depending on the size of your library, and will probably block your browser in that time. My lib contains ~80k images and the script takes 8s to execute in FirefoxDeveloperEdition. Use FirefoxDeveloperEdition or Firefox btw. Chrome has very strict limits on ram usage
THIS IS HOW THE FOLDER THIS SCRIPT IS IN HAS TO LOOK LIKE
daniel@iMac:/tmp/lr$ ls|cat
Adobe_AdditionalMetadata.json
Adobe_faceProperties.json
Adobe_imageDevelopBeforeSettings.json
Adobe_imageDevelopSettings.json
Adobe_imageProofSettings.json
Adobe_imageProperties.json
Adobe_images.json
Adobe_libraryImageDevelop3DLUTColorTable.json
Adobe_libraryImageDevelopHistoryStep.json
Adobe_libraryImageDevelopSnapshot.json
Adobe_libraryImageFaceProcessHistory.json
Adobe_namedIdentityPlate.json
Adobe_variables.json
Adobe_variablesTable.json
AgDNGProxyInfo.json
AgDNGProxyInfoUpdater.json
AgDeletedOzAlbumAssetIds.json
AgDeletedOzAlbumIds.json
AgDeletedOzAssetIds.json
AgDeletedOzSpaceIds.json
AgDevelopAdditionalMetadata.json
AgFolderContent.json
AgHarvestedDNGMetadata.json
AgHarvestedExifMetadata.json
AgHarvestedIptcMetadata.json
AgHarvestedMetadataWorklist.json
AgInternedExifCameraModel.json
AgInternedExifCameraSN.json
AgInternedExifLens.json
AgInternedIptcCity.json
AgInternedIptcCountry.json
AgInternedIptcCreator.json
AgInternedIptcIsoCountryCode.json
AgInternedIptcJobIdentifier.json
AgInternedIptcLocation.json
AgInternedIptcState.json
AgLastCatalogExport.json
AgLibraryCollection.json
AgLibraryCollectionChangeCounter.json
AgLibraryCollectionContent.json
AgLibraryCollectionCoverImage.json
AgLibraryCollectionImage.json
AgLibraryCollectionImageChangeCounter.json
AgLibraryCollectionImageOzAlbumAssetIds.json
AgLibraryCollectionImageOzSortOrder.json
AgLibraryCollectionLabel.json
AgLibraryCollectionOzAlbumIds.json
AgLibraryCollectionStack.json
AgLibraryCollectionStackData.json
AgLibraryCollectionStackImage.json
AgLibraryCollectionSyncedAlbumData.json
AgLibraryCollectionTrackedAssets.json
AgLibraryFace.json
AgLibraryFaceCluster.json
AgLibraryFaceData.json
AgLibraryFile.json
AgLibraryFileAssetMetadata.json
AgLibraryFolder.json
AgLibraryFolderFavorite.json
AgLibraryFolderLabel.json
AgLibraryFolderStack.json
AgLibraryFolderStackData.json
AgLibraryFolderStackImage.json
AgLibraryIPTC.json
AgLibraryImageChangeCounter.json
AgLibraryImageOzAssetIds.json
AgLibraryImageSearchData.json
AgLibraryImageSyncedAssetData.json
AgLibraryImageXMPUpdater.json
AgLibraryImport.json
AgLibraryImportImage.json
AgLibraryKeyword.json
AgLibraryKeywordCooccurrence.json
AgLibraryKeywordFace.json
AgLibraryKeywordImage.json
AgLibraryKeywordPopularity.json
AgLibraryKeywordSynonym.json
AgLibraryOzCommentIds.json
AgLibraryOzFavoriteIds.json
AgLibraryOzFeedbackInfo.json
AgLibraryPublishedCollection.json
AgLibraryPublishedCollectionContent.json
AgLibraryPublishedCollectionImage.json
AgLibraryPublishedCollectionLabel.json
AgLibraryRootFolder.json
AgLibraryUpdatedImages.json
AgMRULists.json
AgMetadataSearchIndex.json
AgOutputImageAsset.json
AgOzSpaceAlbumIds.json
AgOzSpaceIds.json
AgPendingOzAlbumAssetIds.json
AgPendingOzAssetBinaryDownloads.json
AgPendingOzAssets.json
AgPhotoComment.json
AgPhotoProperty.json
AgPhotoPropertyArrayElement.json
AgPhotoPropertySpec.json
AgPublishListenerWorklist.json
AgRemotePhoto.json
AgSearchablePhotoProperty.json
AgSearchablePhotoPropertyArrayElement.json
AgSourceColorProfileConstants.json
AgSpecialSourceContent.json
AgTempImages.json
AgUnsupportedOzAssets.json
AgVideoInfo.json
LrMobileSyncChangeCounter.json
MigratedCollectionImages.json
MigratedCollections.json
MigratedImages.json
MigratedInfo.json
MigrationSchemaVersion.json
sqlite_stat1.json
sqlite_stat4.json
----------------------
Sample output: (excerpt)
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/_MG_7746.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/_MG_7750.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/_MG_7751.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/_MG_7753.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/_MG_7756.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/_MG_7757.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/MVI_7761.MOV
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/_MG_7782.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/_MG_7783.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/_MG_7787.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/_MG_7790.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/_MG_7791.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/MVI_7795.MOV
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-27/MVI_7797.MOV
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7801.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7802.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7810.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7811.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7814.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7815.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7817.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7818.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7819.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7822.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7823.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7828.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7841.CR2
/Volumes/RAID0/Pictures/Lightroom/2017/2017-03-28/_MG_7843.CR2
--------
Copyright 2020 Daniel Troger
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<script>
var json = {
AgTempImages: null,
Adobe_imageProperties: null,
Adobe_images: null,
AgLibraryFile: null,
AgLibraryFolder: null,
AgLibraryRootFolder: null,
};
Object.keys(json).forEach(async (key, i) => {
fetch(key+".json").then(function (stuff) {
stuff.json().then(function (contents) {
window.json[this.key] = contents;
}.bind({key:this.key}));
}.bind({key:key}));
});
do_something_with_the_json();
async function do_something_with_the_json(){
const keys = Object.keys(json);
for (var i = 0; i < keys.length; i++) {
while(!json[keys[i]]){
await new Promise(r => setTimeout(r, 10));
}
}
console.info(json);
let output = [];
json.AgTempImages.forEach(item => {
let image, imgprop, aimg, rootFile, fObj, thefObj, fileName, folder, pathFromRoot, rootFolder; // id_local;
// for (var i = 0; i < json.Adobe_imageProperties.length; i++) {
// imgprop = json.Adobe_imageProperties[i];
// if(imgprop.image === item.image){
// id_local = imgprop.id_local;
// break;
// }
// }
for(i = 0; i < json.Adobe_images.length; i++){ // search for some id_local we need to find the filename
aimg = json.Adobe_images[i];
if(aimg.id_local === item.image){
rootFile = aimg.rootFile;
break;
}
}
for(i = 0; i < json.AgLibraryFile.length; i++){ // search for filename
fObj = json.AgLibraryFile[i];
if(fObj.id_local === rootFile){
thefObj = fObj;
break;
}
}
fileName = thefObj.originalFilename;
for(i = 0; i < json.AgLibraryFolder.length; i++){ // search from folder from root
folder = json.AgLibraryFolder[i];
if(folder.id_local === thefObj.folder){
pathFromRoot = folder.pathFromRoot;
break;
}
}
for(i = 0; i < json.AgLibraryRootFolder.length; i++){ // search for the root folder
rootFolder = json.AgLibraryRootFolder[i];
if(rootFolder.id_local === folder.rootFolder){
output.push(rootFolder.absolutePath+pathFromRoot+fileName);
break;
}
}
});
console.log(output);
document.body.innerHTML = output.join("<br />");
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment