Information about the previous photo in the directory/folder (if 1 file is selected)
Hello! Thanks to your help, I figured out a lot and set up LR for myself. But still a lot of things I want to implement.
Question. I picked one photo from the library and I can see its metadata and information on the side. Can I get information about the metadata of the previous photo at this point?
local LrApplication = import("LrApplication")
local LrTasks = import("LrTasks")
local catalog = import("LrApplication").activeCatalog()
local LrBinding = import("LrBinding")
local LrFunctionContext = import("LrFunctionContext")
local LrProgressScope = import("LrProgressScope")
local LrPrefs = import("LrPrefs")
local prefs = LrPrefs.prefsForPlugin()
function showDialog(context)
local props = LrBinding.makePropertyTable(context)
local fillFormat = props.fillFormat
prefs.fillFormat = fillFormat
updateFill(fillFormat)
end
function updateFill(fillFormat)
LrTasks.startAsyncTask(function()
catalog:withWriteAccessDo("&Фиксация данных: \"STP\"", function()
local photos = catalog.targetPhotos
local countPhotos = #photos
local ProgressBar = LrProgressScope({
title = "Фиксация данных \"STP\" для " .. tostring(countPhotos) .. " файла(ов)"
})
for i, photo in ipairs(photos) do
local settings = photo:getDevelopSettings()
local typeColor = ''
local ConvertToGrayscale = (settings["ConvertToGrayscale"])
if ConvertToGrayscale == true then typeColor = 'M' else typeColor = 'C' end
photo:setRawMetadata("copyName", 'S'..typeColor)
local previousversionFile = GETTING DATA WITH FIELD provider of the PREVIOUS FILE
versionFile = 1 + previousversionFile
photo:setRawMetadata("provider", versionFile)
photo:setRawMetadata("label", 'STP')
photo:setRawMetadata("location", 'Drive')
local fileFormat = photo:getRawMetadata("fileFormat") or ""
if fileFormat == 'TIFF' then
photo:buildSmartPreview()
end
ProgressBar:setPortionComplete(i, countPhotos)
end
ProgressBar:done()
end)
end)
end
LrFunctionContext.callWithContext("theName", showDialog)
Without this line "local previousversionFile = GETTING DATA WITH FIELD provider of the PREVIOUS FILE" everything works.
Here is an example of the code I want to use for file version numbering. To do this, I use the "provider"field. By default, for each photo in this field is set to 0. If I want to create a new version of processing with my hands, I create a virtual copy and run this code. I want to add it so that it took data from the provider field and added 1 and assigned this value to the current file. This can be done by selecting 2 files. But is it possible to do with one active selection (LR does not quickly process the selection and uploading of data if the selected photo is more than one).
Thanks in advance for your help