• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
5

Add metadata after moving file

Explorer ,
Mar 07, 2024 Mar 07, 2024

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.

 

 

TOPICS
macOS , SDK

Views

97

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 09, 2024 Mar 09, 2024

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 10, 2024 Mar 10, 2024

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines