Question
Add metadata to files in another directory when not selected
I can move and rename my files without any problem and add them back in the catalog.
But i'm having trouble how to go further with the moved files.
Adding metadata and so on, spend a whole day searching without any luck
function moveFiles(NewTargetDir, NewFileName, NewFileExtention)
-- counters
local Counter = "1"
local catalog = LrApplication.activeCatalog()
local result = catalog:withWriteAccessDo("Reimport photos", function(context)
photos = catalog:getTargetPhotos()
for loop, photo in ipairs(photos) do
local SourceFile = photo:getRawMetadata("path")
local TargetFile = NewTargetDir .. "/" .. NewFileName .. "-" .. string.format("%02d", Counter) .. "." .. NewFileExtention
LrFileUtils.move(SourceFile, TargetFile)
-- Add to catalog
catalog:addPhoto(TargetFile)
-- increase counter
Counter = Counter + 1
end
end)
end
I have tried to do it all in one loop but always an error.
So next thing is select images in the new directory, but here also errors
function UpdateMetadata(NewTargetDir)
local catalog = LrApplication.activeCatalog()
catalog:setActiveSources(NewTargetDir)
photos = catalog:setActiveSources(NewTargetDir)
for loop, photo in ipairs(photos) do
photo:readMetadata()
<photo: writeMetadata>
< do something else>
LrDialogs.message(photo:getRawMetadata("path"))
end
end
So anypointers would be appreciated
Patrick