Long story, but I have lost about 5 years of extra information in custom fields, also backup. Luckely all this information is saved into a .json file with the images.
So for restoring them I was thinking to create a 'simple' lua script with a dialog for inserting this information back into lightroom.
My steps:
- Select the images where the information of the json file should be applied
- select the jason file
code not 100% correct but this should give an idea of this will work
read the json file and put each value into a variable
ReturnContentFile = LrFileUtils.readFile(file)
strTable = "{ " .. ReturnContentFile .. " }"
strTable = loadstring("return "..strTable)()
return strTable
-- must do the variable stuff
Put for each image the information into my custom fields
local catalog = LrApplication.activeCatalog()
for loop, photo in ipairs(photos) do
photo:readMetadata()
catalog:withPrivateWriteAccessDo(function(context)
photo:setPropertyForPlugin( _PLUGIN, 'MetaDataFile', "CFMetadata-"..CFMetadataFile)
photo:setPropertyForPlugin( _PLUGIN, 'AFFilmFormat', AFFilmFormat)
photo:setPropertyForPlugin( _PLUGIN, 'AFScanMethod', AFScanMethod)
photo:setPropertyForPlugin( _PLUGIN, 'AFScanEquipment', AFScanEquipment)
photo:setPropertyForPlugin( _PLUGIN, 'AFLightSource', AFLightSource)
photo:setPropertyForPlugin( _PLUGIN, 'AFDeveloppedAt', AFDeveloppedAt)
photo:setPropertyForPlugin( _PLUGIN, 'AFDevelopper', AFDevelopper)
photo:setPropertyForPlugin( _PLUGIN, 'AFDilution', AFDilution)
photo:setPropertyForPlugin( _PLUGIN, 'AFDevTime', AFDevTime)
photo:setPropertyForPlugin( _PLUGIN, 'AFDevNotes', AFDevNotes)
photo:setPropertyForPlugin( _PLUGIN, 'AFpushpull', AFpushpull)
photo:setPropertyForPlugin( _PLUGIN, 'AFFilmStock', StrFilmStock)
photo:setPropertyForPlugin( _PLUGIN, 'AFLightmeter', AFLightmeter)
photo:setPropertyForPlugin( _PLUGIN, 'ScanDevInfo', "ScanDevInfo-"..CFMetadataFile)
end )
end
Is this a good approach ?