substring in a simple automation chain
Hi everyone,
I have a very simple automation chain in witch I extract the filemane to insert into a document title.
In a fist time, I declare a variable “varNomFichier” whith value @{Document.getProperty(“file:filename”)}, and in a second time, I execute a Document.SetProperty, with xpath dc:title and value @{Context[“varNomFichier”]}.
The trouble is, my title take the name of the entire file name, with the file extension.
Can you tell me how to use a substring like expression to delete the “.extension” to keep only the file name ?
Thank you.
A great tank you for your answers, it works !! (using, @{org.apache.commons.io.FilenameUtils.removeExtension(Document[“file:content”].filename)}
:D
If you prefer to stay in “regular” automation (not using Automation Script) you probably can still use some java utils that are loaded by Nuxeo, like Apache FilenameUtils:
Context.FetchDocument
Context.SetVar:
name: blobFileName
value: @{Document["file:content"].filename}
Document.SetProperty:
xpath: dc:title
save: true
value: @{org.apache.commons.io.FilenameUtils.removeExtension(blobFileName)}
Notice you also can also just write:
Context.FetchDocument
Document.SetProperty:
xpath: dc:title
save: true
value: @{org.apache.commons.io.FilenameUtils.removeExtension(Document["file:content"].filename)}