Copy link to clipboard
This should be easy, but there doesn't seem to be an obvious way to get the LrFolder of an LrPhoto in the API. For collections, there's photo:getContainedCollections(), but no equivalent for folders.
My best attempt:
local path = photo:getRawMetadata("path")
local _, _, folderPath, filename = string.find(path, "^(.*)/([^/]*)$")
The string processing is non-portable (assumes "/" as path separator) and krufty. It would help if there were a LrFileUtils.parentDirectory function, but there is not.
Is there anything in the API to improve on this?
Use LrPathUtils to get the parent directory:
catalog:getFolderByPath (LrPathUtils.parent (photo:getRawMetadata ("path")))
[Use the reply button under the first post to ensure replies sort properly.]