Skip to main content
Inspiring
February 20, 2026
Answered

SDK during export rename exported file to uuid.jpg

  • February 20, 2026
  • 2 replies
  • 49 views

During export I want to rename my exported images to <uuid>.jpg.

Is there a smarter way then my code below?

exportPath = "D:/Temp"
for i, rendition in exportSession:renditions(renditionParams) do
-- Wait for the upstream task to finish its work on this photo.
local success, pathOrMessage = rendition:waitForRender()
if (success == true) then
local newFileName = LrPathUtils.child(exportPath, rendition.photo:getRawMetadata("uuid") .. ".jpg")
local result, message = LrFileUtils.move(pathOrMessage, newFileName)
end
end

 

Correct answer johnrellis

[View this post in your web browser. It contains formatting and images that don't appear in email.]

 

You’d have to do it one photo at a time, just as you were in the original script, e.g.

for _, photo in ipairs (photos) {
exportSettings.LR_tokenCustomString = photo:getRawMetadata("uuid")
...LrExportSession {
photosToExport = {photo},
exportSettings = exportSettings}
...}

 

I don’t know of any way to export a whole batch and do that rename.

2 replies

johnrellis
johnrellisCorrect answer
Legend
February 21, 2026

[View this post in your web browser. It contains formatting and images that don't appear in email.]

 

You’d have to do it one photo at a time, just as you were in the original script, e.g.

for _, photo in ipairs (photos) {
exportSettings.LR_tokenCustomString = photo:getRawMetadata("uuid")
...LrExportSession {
photosToExport = {photo},
exportSettings = exportSettings}
...}

 

I don’t know of any way to export a whole batch and do that rename.

Inspiring
February 23, 2026

I was not clear in my question and example code.

My question was whether it is possible to rename multiple photos during export.

The information / answer provided answers both questions, namely how to rename a single photo and that it is not possible to rename multiple photos in this way.

Thanks

johnrellis
Legend
February 21, 2026

[View this post in your web browser. It contains formatting and images that don't appear in email.]

 

When creating the LrExportSession, start with these settings:

 

Then before creating the LrExportSession, do:

settings.tokenCustomString = photo:getRawMetadata ("uuid")
...LrExportSession (settings)...

 

Inspiring
February 21, 2026

I can’t get it to work.

From tjhe SDK documentation I have to provide a table with  photosToExport and  exportSettings.
I included the LR_tokenCustomString = photo:getRawMetadata("uuid"), but this doesn't work because photo is not declared, which is correct.

Which part am I missing?

LrTasks.startAsyncTask(function()
LogUtil.emptyLogFile()
myLogger = LogUtil.getDefaultLogger()
myLogger:info("Starting")

-- Collect photos to operate on
local targetPhotos = catalog.targetPhotos
local targetPhoto = catalog:getTargetPhoto()

local exportPath = LrPathUtils.child("D:/Temp", "UUID test")
LrFileUtils.createAllDirectories(exportPath)
myLogger:info("exportPath", exportPath)
local photos = catalog:getTargetPhotos()

local export_session = LrExportSession {
photosToExport = photos,
exportSettings = {
-- temp folder
LR_export_destinationPathPrefix = exportPath,

-- full size jpeg
LR_format = "JPEG",
LR_extensionCase = "lowercase",
LR_tokens = "{{custom_token}}",
LR_tokenCustomString = photo:getRawMetadata("uuid"),
}
}

export_session:doExportOnCurrentTask()
for i, rendition in export_session:renditions() do
local success, pathOrMessage = rendition:waitForRender()
end
end
)