Copy link to clipboard
Copied
I understand that I can set LR_renamingTokensOn to true, but I would like to replace all spaces in the file name with an underscore and remove characters not in the range A-Z and 0-9. What's the easiest way to achieve this?
Copy link to clipboard
Copied
Well, if it's an ad-hoc export, i.e. one which your plugin initates via an LrExportSession method, then you can name stuff whatever you want to - just set LR_tokens to {{custom_token}} then set LR_tokenCustomString to whatever you want (a filtered filename base).
Are you writing a:
* export/publish plugin
* export filter to be used with any export/publish service.
* something else (e.g. menu function), which could use ad-hoc exporting
?
Copy link to clipboard
Copied
Hi Rob,
I can set LR_tokens since the export is done via a custom initiation of LrExportSession, but I find the documentation on it confusing.
I'm writing an export plugin.
Can you provide some sample code for using {{custom_token}} that would run a regular expression on the filename?
Thanks.
Copy link to clipboard
Copied
local photo = catalog:getTargetPhoto()
local sesn = LrExportSession {
photosToExport = { photo },
exportSettings = {
-- ... (determine from export preset) - whatev you want, just be sure you set export directory: LR_export_destinationPathPrefix
LR_tokens = "{{custom_token}}",
LR_tokenCustomString = LrPathUtils.removeExtension( photo:getFormattedMetadata( 'fileName' ) ):gsub( "[ %c]", "" ) -- remove spaces and control characters
},
}
sesn:doExportOnNewTask()
Find more inspiration, events, and resources on the new Adobe Community
Explore Now