cancel
Showing results for 
Search instead for 
Did you mean: 

substring in a simple automation chain

Charp_Aton
Confirmed Champ
Confirmed Champ

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.

3 REPLIES 3

Jackie_A
Confirmed Champ
Confirmed Champ

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

ThibArg_
Star Contributor
Star Contributor

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

Charp_Aton
Confirmed Champ
Confirmed Champ

A great tank you for your answers, it works !! (using, @{org.apache.commons.io.FilenameUtils.removeExtension(Document["file:content"].filename)}

😄