cancel
Showing results for 
Search instead for 
Did you mean: 

How to replace "+" by "_" in document name with javascript

castelsarrasin
Confirmed Champ
Confirmed Champ

Hello,

I use alfresco 5.2.0f.

Actually my colleagues use some name with "+" on the document.name

Exemple : XXXX + XXX.pdf

With a javasript i move the file in a folder and the folder get the name ot the filename.

I need to know how i can replace all the "+"  by "_" for exemple.

Is someone know how to do ? Is there a javascript to save me from this "+" ?

In the end i want to extend this script for all the shared files.

Thank you by advance for you collaboration.

2 REPLIES 2

jljwoznica
Star Collaborator
Star Collaborator

You can use the replace() function to do this.

Thank you for you answer,

Can you give me a sample of the javascript please ?

I'm a noob for it...

Here is the rename and move folder, i would like to have a replace for the name if there is a "+" in the props BDCSEDIT.

var Descr = document.properties["test:BDC-SEDIT-propriete"];
var libelle =  document.properties["test:BDC-SEDIT-ObjetCommande"];
var tiers =  document.properties["test:BDC-SEDIT-LibelleTiers"];
var parent = document.parent;
var myfolder = parent.childByNamePath(Descr + "_" + tiers + "_" + libelle);
if (myfolder === null) {
    myfolder = parent.createFolder(Descr + "_" + tiers + "_" + libelle);
}
document.move(myfolder);

Thank you for your help !