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.

0 votes

2 answers

312 views

ANSWER



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)}
0 votes



I think the easiest way will be to use an automation script as you can use substring in javascript

0 votes