Copy link to clipboard
Copied
I don't know of this is possible, I need to rename a lot of images and then add metadata to them.
short code
LrFileUtils.copy(SourceFile, TargetFile)
--------- Add to catalog --------
local result = catalog:withWriteAccessDo("Reimport photos", function(context)
RenamedFile = catalog:addPhoto(TargetFile)
end)
for _, newphoto in ipairs(RenamedFile) do
catalog:withPrivateWriteAccessDo(function(context)
newphoto:setPropertyForPlugin( _PLUGIN, 'xxx', yyy)
end)
end
There is no metadata added to the new image.
Copy link to clipboard
Copied
In a plugin I wrote several years ago, I found that the LrPhoto returned by catalog:addPhoto() wasn't usable. I had to call catalog:findPhotoByPath() to retreive the new LrPhoto. Here's the code fragment:
--[[ Import the image and then get access to it with
findPhotoByPath(). We can't use the results of addPhoto()
because applyDevelopSettings() acts wonky with it. ]]
Util.withWriteAccessDo ("Import image", function ()
catalog:addPhoto (path)
end)
local photo = catalog:findPhotoByPath (maskPath)
Most likely a bug, but I couldn't narrow it down and it wasn't worth my time to report it.
Copy link to clipboard
Copied
John,
Indeed, that's why I had installed your debug plugin. Could not understand why.
For now as my structure has a unique name I have used find by name solution. Works fine for me.