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

cancel
Showing results for 
Search instead for 
Did you mean: 
castelsarrasin
Active Member II

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

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
Community Manager
Community Manager

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

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

castelsarrasin
Active Member II

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

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 !